Skip to content

Instantly share code, notes, and snippets.

@toadkicker
Last active December 21, 2015 14:48
Show Gist options
  • Select an option

  • Save toadkicker/6321984 to your computer and use it in GitHub Desktop.

Select an option

Save toadkicker/6321984 to your computer and use it in GitHub Desktop.
String.prototype.isValidEmail = function() {
var filter = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
if (!filter.test(this)) {
return false;
} else {
return true
}
}
@toadkicker

Copy link
Copy Markdown
Author

Updated regex to be compliant with email RFC 2822 with the exception of double quotes and square brackets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment