/********************
Function Name: Istelephone
function function: fixed, mobile phone number check function, return True, reverse, return false
function parameters: obj, number to be checked
Check rule:
(1) Number, "(", ")" and "-"
(2) The phone number is 3 to 8 digits
(3) If the phone number contains an area code, then the area code is three-bit or four-bit
(4) The area code is separated by "(", ")" or "-" and other parts
(5) The mobile phone number is 11 or 12 bits, if 12 bits, then the first digit is 0
(6) The first and second digits of the 11-digit mobile phone number are "13"
(7) The second and third digits of the 12-digit mobile phone number are "13"
********************/
function Istelephone (obj) {//Regular judgment
var pattern=/(^[0-9]{3,4}\-[0-9]{3,8}$) | (^[0-9]{3,8}$) | (^\ ([0-9]{3,4}\) [0-9]{3,8}$] | (^0{0,1}13[0-9]{9}$) | (^0{0,1}14[0-9]{9}$) | (^0{0,1}15[0-9]{9}$) | (^0{0,1}17[0-9]{9}$) | (^0{0,1}18[0-9]{9}$)/;
if (pattern.test (obj)) {
return true;
}else{
return false;
}
}
JS mobile phone number and phone number verify regular expressions