Skip to content

Instantly share code, notes, and snippets.

@alexander-young
Created July 6, 2017 16:09
Show Gist options
  • Save alexander-young/3b822515bbde2619a002e0f85125629a to your computer and use it in GitHub Desktop.
Save alexander-young/3b822515bbde2619a002e0f85125629a to your computer and use it in GitHub Desktop.
Email and Phone Regex JS
function isPhone(phone) {
var regex = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/;
return regex.test(phone);
}
function isEmail(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