This article mainly introduces the JS combined with the realization of the domestic mobile phone number section check method and the use of JS and jquery to achieve a simple check cell phone number of examples, very simple and practical, the need for small partners can refer to.
Attach a Utils object, containing a check cell function, a formatted return data function
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The |
|
Verify the phone number of the 130-139,150-159,180-189 number section
?
1 2 3 4 5 6 7 8 |
<script type= "Text/javascript" > var Myreg =/^ (((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1})) +D{8}) $/; if (!myreg.test ("#phone"). Val ()) {alert (' Please enter a valid cell phone number!) '); return false; } </script> |
The above code is debugged under jquery.
Code that doesn't require jquery
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22-23 |
function Validatemobile (MOBILE) {if (mobile.length==0) {alert (' Please enter your mobile number! '); Document.form1.mobile.focus (); return false; } if (mobile.length!=11) {alert (' Please enter a valid cell phone number!) '); Document.form1.mobile.focus (); return false; var Myreg =/^ ((13[0-9]{1}) | ( 15[0-9]{1}) | (18[0-9]{1})) +D{8}) $/; if (!myreg.test (mobile)) {alert (' Please enter a valid cell phone number!) '); Document.form1.mobile.focus (); return false; } } |
The above mentioned is the entire content of this article, I hope you can enjoy.