The following are some regular expressions for js verification phone numbers. I have collected them from the Internet, but they are all excellent products. They are specialized in mobile phone numbers and phone numbers.
Function checkPhone (phone)
{
// Verify the phone number, including the phone number 153,159
If (phone = ""){
Alert ("the phone number cannot be blank! ");
Return false;
}
If (phone! = ""){
Var p1 =/^ ([0 +] d {2, 3 }-)? (0d {2, 3 })-)? (D {7, 8}) (-(d {3 ,}))? $ /;
Var me = false;
If (p1.test (phone) me = true;
If (! Me ){
// Alert ('Sorry, www.45it.com the phone number you entered is incorrect. Use-to separate the area code from the phone number ');
Return false;
}
}
Return true;
}
Mobile phone number verification
String. prototype. isTel = function ()
{
// "Compatible format: Country Code bKjia. c0m (2 to 3 digits)-area code (2 to 3 digits)-telephone number (7 to 8 digits)-extension number (3 digits )"
// Return (/^ ([0 +] d {2, 3 }-)? (0d {2, 3 })-)? (D {7, 8}) (-(d {3 ,}))? $/. Test (this. Trim ()));
Return (/^ ([0 +] d {2, 3 }-)? (0d {2, 3})-) (d {7, 8}) (-(d {3 ,}))? $/. Test (this. Trim ()));
}
// Verify the mobile phone number
String. prototype. isMobile = function (){
Return (/^ (? : 13d | 15 [89])-? D {5} (d {3} | * {3}) $/. test (this. Trim ()));
}
Phone number verification
Function CheckNum () {// phone Verification
Var InputValue = document. gsjbxxBean. dh. value;
Var reg =/^ ([0-9] | [-]) + $/g;
Var isValid
Isvalid1_reg.exe c (InputValue)
If (! IsValid ){
Return false
}
Return true
}
Check the phone number
Function isTel (str ){
Var reg =/^ ([0-9] [-]) + $/g;
If (str. length <7 str. length> 18 ){
Return false;
}
Else {
Return reg.exe c (str );
}
}