Skip to content

Instantly share code, notes, and snippets.

@shubham7298
Created December 28, 2018 08:49
Show Gist options
  • Save shubham7298/5a8a7b0cc0236f20158370fd6cadb476 to your computer and use it in GitHub Desktop.
Save shubham7298/5a8a7b0cc0236f20158370fd6cadb476 to your computer and use it in GitHub Desktop.
Validate email in JS using regex
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\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,}))$/;
return re.test(String(email).toLowerCase());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment