Skip to content

Instantly share code, notes, and snippets.

@jayvi
Forked from KirillUnited/checkPhone.js
Created October 27, 2020 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayvi/38dea7cd5ea3c9eabee00ca64f5be4f8 to your computer and use it in GitHub Desktop.
Save jayvi/38dea7cd5ea3c9eabee00ca64f5be4f8 to your computer and use it in GitHub Desktop.
phone number validation
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