Skip to content

Instantly share code, notes, and snippets.

@rowej83
Created June 4, 2014 23:42
Show Gist options
  • Save rowej83/35480c5e42fb5cfcb41e to your computer and use it in GitHub Desktop.
Save rowej83/35480c5e42fb5cfcb41e to your computer and use it in GitHub Desktop.
Checks if input is a valid email address.
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i);
return pattern.test(emailAddress);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment