This cell phone number is the correct validation function can be said to be the latest support, which has a detailed description, no matter what the next increase in the number of sections we are very easy to modify a little bit.
JavaScript phone number Regular expression validation function
Copy Code code as follows:
IP and domain name validation functions
function Checkip ()
{
var iparray,ip,j;
ip = document.ipform.ip.value;
if (/[a-za-z_-]/.test (IP)) {
if (Ip.indexof ("") >=0) {
IP = ip.replace (//g, "");
Document.ipform.ip.value = IP;
}
if (Ip.tolowercase (). IndexOf ("http://") ==0) {
ip = ip.slice (7);
Document.ipform.ip.value = IP;
}
if (!/^ ([\w-]+\.) + ((COM) | (NET) | (org) | (gov\.cn) | (info) | (cc) | (com\.cn) | (net\.cn) | (org\.cn) | (name) | (Biz) | (TV) | (CN) | (mobi) | (name) | (SH) | (AC) | (IO) | (TW) | (com\.tw) | (HK) | (COM\.HK) | (WS) | (travel) | (US) | (tm) | (LA) | (me\.uk) | (org\.uk) | (ltd\.uk) | (plc\.uk) | (in) | (EU) | (IT) | (JP)) $/.test (IP)) {
Alert ("Not the correct domain name");
Document.ipform.ip.focus ();
return false;
}
}
else{
Iparray = Ip.split (".");
j = Iparray.length
if (j!=4)
{
Alert ("Not the correct IP");
Document.ipform.ip.focus ();
return false;
}
for (Var i=0;i<4;i++)
{
if (iparray[i].length==0 | | iparray[i]>255)
{
Alert ("Not the correct IP");
Document.ipform.ip.focus ();
return false;
}
}
}
}
Cell Phone number verification function
function Checkmobile () {
var smobile = Document.mobileform.mobile.value
if (!) ( /^1[3|4|5|8][0-9]\d{4,8}$/.test (Smobile))) {
Alert ("Not a full 11-digit cell phone number or the correct number of the top seven");
Document.mobileform.mobile.focus ();
return false;
}
}
Zip Code validation function
function Checkzip () {
var szip = Document.zipform.zip.value
if (!) ( /^\d{4,6}$/.test (Szip))) {
Alert ("Please enter the first 4-6 digits of the ZIP code");
return false;
}
}
Area code Verification
function Checkzone () {
var szone = Document.zoneform.zone.value
if (!) ( /^0\d{2,6}$/.test (Szone))) {
Alert ("Please enter a 3-7-bit area code that starts with" 0 ");
return false;
}
}
ID Card Verification
function Checkid () {
var SID = document. IDform.userid.value
if (!) ( /^\d{15}$|^\d{18}$|^\d{17}[xx]$/.test (SID))) {
Alert ("Please enter 15-or 18-digit ID number");
Document. IDform.userid.focus ();
return false;
}