Created
July 6, 2017 16:09
-
-
Save alexander-young/3b822515bbde2619a002e0f85125629a to your computer and use it in GitHub Desktop.
Email and Phone Regex JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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