title: Validate multiple input type="email" using Javascript
body: <p>I have one form which contain multiple email field so this email to be submitted in database but before that it should validate to avoid duplication, (multiple email fields generated by click on  add more button which is present in form ).</p>
  
  <p>I have written ValidateEmail script to avoid duplication however it will work for only one email field but not successfull  for multiple email field.</p>
  
  <p>issue:
  1)  if we type email id in first field it will go for validation and check email exist or not if exist disable submit button if not exist enable button.</p>
  
  <p>2)  if  we type  type email id in second field and after validation it return email not exist then it will enable submit button however in first email field contain duplicate email. </p>
  
  <p>3) if all email fields not contain duplicate values then only enable submit button else it should remain disabled..</p>
  
  <pre><code>&lt;form&gt;
  &lt;div&gt;
  &lt;input type="email" name="email[]" class="email" onblur="validate_email(this)" /&gt;   // initially single filed
  
  // This additional email fields created when click on add more button 
  
  &lt;input type="email" name="email[]" class="email" onblur="validate_email(this)" /&gt; 
  &lt;input type="email" name="email[]" class="email" onblur="validate_email(this)" /&gt;
  &lt;input type="email" name="email[]" class="email" onblur="validate_email(this)" /&gt;
  &lt;/div&gt;
  
  &lt;button class="add_more"&gt;Add more&lt;/button&gt;   // this will append extra email fileds
  &lt;/form&gt;
  
  &lt;script&gt;
  // This is the script it will check whether email already exist or not
  function ValidateEmail(data) {
          var email_id = data.value;
          $.ajax({
              type: "POST",
              url: "&lt;?= base_url('controller') ?&gt;",
              data:{
                 email_id:email_id 
              },
              dataType: 'json',
              success: function (response) {
                  if(response.exist){
                         // disable submit button and show error
  
                      }
                       else{
                        //enable submit field and hide error
  
                          }
              },
              error: function (jqXHR, textStatus, errorMessage) {
                  console.log(errorMessage); // Optional
              }
          });
      }
  
  &lt;/script&gt;
  </code></pre>