Three JS verification of mobile phone number example

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Example </title>

<body>

Verify mobile phone Number one

String.prototype.ismobile = function () {
Return (/^ (?: 13d|15[89])-?d{5} (D{3}|*{3}) $/.test (This.trim ());
}


Return (/^ (?: 13d|15[89])-?d{5} (D{3}|*{3}) $/.test (This.trim ());

var mobile =/^ ((d{3}) | ( d{3}-))? 13d{9}|15[0-9]d{8}$/

Regular expression section:
D Represents a number
{7,8} represents 7-8 digits (indicates phone number)
{3,} represents an extension number
d{2,3} represents the area code
+]d{2,3} represents the international area code
^13d{5,9}$///130–139. At least 5 digits, up to 9 digits
/^153d{4,8}$///Unicom 153. At least 4 digits, up to 8 digits
/^159d{4,8}$///Mobile 159. At least 4 digits, up to 8 digits

Verify Two

function Checkmobile (MOBILE)   
{    
if (Mobile!= "") {&NBSP;&NB sp;   
var reg0 =/^13d{5,9}$/;  
var reg1 =/^153d{4,8}$/;  
var REG2 =/^159d{4,8}$/;  
var reg3 =/^0d{10,11}$/;
var reg4 =/^150d{4,8}$/;
var reg5 =/^158d{4,8}$/;
var reg6 =/^15d{5,9}$/;
var my = false;  
if (reg0.test (mobile) my=true;  
if (reg1.test (mobile)) MY=TRUE;&N bsp; 
if (reg2.test (mobile)) my=true;  
if (reg3.test (mobile)) My=true;
if (reg4.test (mobile) my=true;  
if (reg5.test (mobile)) my=true;  
if (reg6.test (mob ile) my=true;  
if (!my) {
//alert (' Sorry, you have entered a phone or PHS number with errors. ');    
return false;  
}  
return true;  
}   
}

Verify Three

var cellphone=/^ (((1[0-9]{1}[0-9]{1})) +d{8}) $/;
if (!cellphone.test (Form1.messagehandset.value))
{
Alert (' Please enter a valid cell phone number! ');
Form1.messagehandset.focus ();
return false;
}

</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.