Created
August 15, 2014 19:56
-
-
Save denniszhao/21c24ee200291fb7a6e6 to your computer and use it in GitHub Desktop.
Return true if valid phone number
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 isValidUSPhoneNum(number) { | |
var USPhoneNumRegex = /^(?:\([2-9]{3}\)(?:[\s]*|[-])|[2-9]{3}(?:[\s]*|[-]))[0-9]{3}(?:[\s]*|[-])[0-9]{4}$/; | |
// booleanize | |
return !!number.match(USPhoneNumRegex); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment