This file contains 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
/******************************************************* | |
* validatePhone | |
* return true if the string 'p' is a valid phone | |
*******************************************************/ | |
function validatePhone(p){ | |
var phoneRe = /^[(]{0,1}[0-9]{3}[)]{0,1}[-\s\.]{0,1}[0-9]{3}[-\s\.]{0,1}[0-9]{4}$/; | |
var digits = p.replace(/\D/g, ""); | |
return phoneRe.test(digits); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment