Last active
December 10, 2015 22:38
-
-
Save corleonis/4503419 to your computer and use it in GitHub Desktop.
Validate list of comma separated emails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(function() { | |
var isValidEmailAddress = function(emailAddress) { | |
var pattern = new RegExp(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i); | |
return pattern.test(emailAddress); | |
}; | |
var validateCommaSeparatedEmails = function(emailAddresses) { | |
var emails = value.split(','); | |
var valid = true; | |
for (var i = 0; i < emails.length; i++) { | |
value = jQuery.trim(emails[i]) | |
valid = valid && isValidEmailAddress(value); | |
} | |
return valid; | |
}; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment