Skip to content

Instantly share code, notes, and snippets.

@LB-Digital
Created July 17, 2018 12:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LB-Digital/e0a5448362985055375963eb06b6e980 to your computer and use it in GitHub Desktop.
Save LB-Digital/e0a5448362985055375963eb06b6e980 to your computer and use it in GitHub Desktop.
Simple REGEX based JavaScript function to validate an email address
function validEmail(address) {
// Regular Express from http://emailregex.com
const emailRegex = /^(([^<>()\[\]\\.,;:\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,}))$/;
if (emailRegex.test(address)) return true;
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment