Skip to content

Instantly share code, notes, and snippets.

@KirillUnited
Created June 28, 2018 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KirillUnited/9bff6d36e2ed1c39b5e85b8390ac8660 to your computer and use it in GitHub Desktop.
Save KirillUnited/9bff6d36e2ed1c39b5e85b8390ac8660 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