/********************
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}$)/;
if (pattern.test (obj))
{
return true;
}
Else
{
return false;
}
}
function Isphonenumber (str) non-regular judgment
{
var I,strlengh,tempchar;
Str=cstr (str);
if (str== "") return false;
Strlength=str.length;
for (i=0;i<strlength;i++)
{
Tempchar=str.substring (i,i+1);
if (! ( tempchar==0| | tempchar==1| | tempchar==2| | tempchar==3| | tempchar==4| | tempchar==5| | tempchar==6| | tempchar==7| | tempchar==8| |tempchar==9| | tempchar== ';-';))
{
Alert ("Phone number can only enter numbers and dashes");
return (false);
}
}
return (true);
}
JS Verify phone number is legal