See a lot of code on the Internet is very complex, but also include the beginning of the Chinese 86,17951, in fact, who will fill out so much, but is to test whether they are the number of digits right, the beginning is not written wrong. Below we from Baidu Encyclopedia mobile phone number history to look: Now mobile phone number segment has unicom, mobile and telecommunications.
Telecom
China Telecom mobile phone number start number
2G/3G segment (CDMA2000 network) 133, 153, 180, 181, 189
Section 4G, 177
Unicom
China Unicom mobile phone number start number
2G segment (GSM network) 130, 131, 132, 155, 156
3G Internet Card 145
3G segment (WCDMA network) 185, 186
4G segment 176, 185[1]
Move
China Mobile phone number start number
The 2G segment (GSM network) has 134x (0-8), 135, 136, 137, 138, 139, 150, 151, 152, 158, 159, 182, 183, 184.
Section 3G (TD-SCDMA Network) has 157, 187, 188
3G Internet Card 147
Section 4G, 178
From the above we can see that the first one is "1", the second is "3,4,5,7,8", the third is "0-9", and the third is the number "0-9". So we can come up with a regular expression that matches the current phone number validation.
var reg =/^1[3|4|5|7|8][0-9]{9}$/; Validation Rule
var phonenum = ' 15507621999 '//Mobile number
var flag = reg.test (phonenum);//true
But have you ever thought that maybe this second code might add one at a time, like starting with 16? 19 to begin with. Who knows the future, our code to ensure that a few years no problem, so you can not verify the second rule:
code from http://caibaojian.com/phone-regexp.html
var reg =/^1[0-9]{10}$/;
Original link: JS Latest mobile phone number check the regular expression of copyright, reprint, please specify the source, offenders must investigate.
Annotated source format: Front-End development blog (http://caibaojian.com/phone-regexp.html) original link: http://caibaojian.com/phone-regexp.html