-
-
Save jayvi/38dea7cd5ea3c9eabee00ca64f5be4f8 to your computer and use it in GitHub Desktop.
phone number validation
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
function checkPhone(phone) { | |
var phoneVal = phone.val(); | |
var reg = /^(\s*)?(\+)?([- ():=+]?\d[- ():=+]?){10,14}(\s*)?$/; | |
console.log(reg); | |
if (!reg.test(phoneVal)) { | |
phone.addClass("error"); | |
return false; | |
} else { | |
phone.removeClass("error"); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment