We commonly used to verify the phone number of JS
--jquery Mobile phone Number verification
Cell Phone verification
function Ismobil (s)
{
//var reg=/^ ((13[0-9)) | ( 15[^4,\D]) | (18[0,5-9]) \d{8}$/;
var reg=/^1\d{10}$/;
if (!reg.exec (s)) {return
false;
}
return true;
}
Here we have a brief list of issues to be noted:
* Input box, can only enter numbers;
* In the process of input to display the contents of the input synchronously;
* Determine whether the input mobile phone number is in the correct format;
* To judge the place where the mobile phone belongs;
1, page structure
<! doctype html>
The operation of the mobile phone number through the structure of the code we can easily find our corresponding operations, such as input code or paste code, etc. function ckphonelast (n) { if (
n.value.length!=11) { $ (' #phone_showtip '). HTML ("Please enter the correct phone number"); }else{ var partten = /^1 [3,5,8]\d{9}$/; if (Partten.test (N.value)) {
ckbelong (N.value); }else{//is not the cell phone number
$ (' #phone_showtip '). HTML ("Please enter the correct phone number"); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP}  }} function ckphone (n) {
$ (' #phone_showtip '). HTML (""); $ ("#phone_belong"). HTML (""); var ck=
False &nBsp; n.value=n.value.replace (/\d/g, ""); if (n.value.length>11) { //can only input 11 digits
n.value=n.value.substring (0,11); &NBSP;&NBSP;&NBSP;&NBSP} if (n.value.length<=3) {
In order to display the previous table $ (' #phone_showtip '). HTML (n.value); &NBSP;&NBSP;&NBSP;&NBSP} if (n.value.length>3) {
$ (' #phone_showtip '). HTML (n.value.substring (0,3)). Append (" "). Append (N.value.substring (3)); &NBSP;&NBSP;&NBSP;&NBSP} if (n.value.length>7) { $ (' #phone_showtip '). HTML (n.value.substring (0,3)). Append (" "). Append (n.value.substring (3,7)).
Append (" "). Append (n.value.substring (7)); &NBSP;&NBSP;&NBSP;&NBSP} if (n.value.length==11) { var partten = /^1[3,5,8]\d{9}$/; if (Partten.test (N.value)) {
ck=true; }else{//is not the cell phone number
$ (' #phone_showtip '). HTML ("Please enter the correct phone number");
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP} } if (CK) {
ckbelong (N.value); &NBSP;&NBSP;&NBSP;&NBSP}}