JS Latest mobile phone number check regular expression of __ regular expression

Source: Internet
Author: User

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

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.