Skip to content

Instantly share code, notes, and snippets.

@erberg-snippets
Created December 10, 2013 18:39
Show Gist options
  • Save erberg-snippets/7895723 to your computer and use it in GitHub Desktop.
Save erberg-snippets/7895723 to your computer and use it in GitHub Desktop.
/**
* Takes a string and returns true if its a valid email address.
* @param {String} email Email address to be tested for validity.
* @return {Boolean} True if valid email, false if not.
*/
function isValidEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment