Created
June 28, 2018 08:42
-
-
Save KirillUnited/9bff6d36e2ed1c39b5e85b8390ac8660 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