title: Comma separated email validation
body: <p>I am using the following link for validating email:
  <a href="http://jquerybyexample.blogspot.com/2011/04/validate-email-address-using-jquery.html" rel="nofollow">http://jquerybyexample.blogspot.com/2011/04/validate-email-address-using-jquery.html</a></p>
  
  <p>I am using this function to validate my email address using js:</p>
  
  <pre><code>validateEmail = (sEmail) -&gt;
    filter = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/
    if filter.test(sEmail)
      true
    else
      false
  $(document).ready (e) -&gt;
    $("#invitation_form").submit -&gt;
      sEmail = $("#invitation_email").val().split(',')
      email=0
      for email in [0..sEmail.length]
        if $.trim(email).length is 0
          $("h2").append("&lt;div class='alert alert-error'&gt;Please review the problems below&lt;/div&gt;")
          $("#invitation_email").attr("placeholder", "Email can't be blank")
          return false
        if validateEmail(email)
        else
          alert sEmail
          email++
          # $("h2").append("&lt;div class='alert alert-error'&gt;Please review the problems below&lt;/div&gt;");
          # $("#invitation_email").val('')
          # $("#invitation_email").attr("placeholder", "Please enter valid email")
          # return false
  </code></pre>
  
  <p>This is validating my email properly if I put only one email. But in my email text field I have to put many comma separated emails and then validate each email individually. For that I had put split(','), and the added the for loop but the validation is not done properly. If I put 'example1@email.com, example2@email.com', then its going in the else block which is for invalid emails. In the alert I am getting the individual emails but not getting how to validate each email individually.
  Can someone please help me in this?
  Thanks in advance.</p>