JS regular expression to verify the mobile phone number or phone number)

Source: Internet
Author: User

China telecom operator mobile phone number segment:

China Mobile segment 134, 135, 136, 137, 138, 139, 150, 151, 152, 157, 158, 159, 147 [1], 182, 183 china Unicom CIDR Block 130, 131, 132, 145, 155, 156, 185, and 186) china Telecom segment 133, 153, 180, 181, 189

Description:Currently, China uses 11 mobile phone numbers, each of which has a different encoding direction: the first 3 digits --- network identification number; the 4-7 digits --- region encoding; The 8-11 digits --- user number.

--------------------------

# Starting with 13,158,159
/^ (? : 13 \ d | 15 [89])-? \ D {5} (\ D {3} | \ * {3}) $/

# Starting with 13, 14, 15, and 18
/^ (? : 13 \ d | 14 | 15 | 18 )-? \ D {5} (\ D {3} | \ * {3}) $/

Phone number format verification: (021-xxxx, 139xx)
RegEx:/(^ [0-9] {3, 4} \-[0-9] {7, 8} $) | (^ [0-9] {7, 8} $) | (^ \ ([0-9] {3, 4} \) [0-9] {3, 8} $) | (^ 0 {0, 1} 13 [0-9] {9} $ )/

Mobile phone number verification:
13,158,159
/^ (? : 13 \ d | 15 [89])-? \ D {5} (\ D {3} | \ * {3}) $/

13, 15, 18
/^ 1 [3 | 5 | 8] [0-9] \ D {4, 8} $/

---------------------------------------------

JS Regular Expression verification indicates whether the input is a mobile phone number or phone number

First give the original link: http://www.cnblogs.com/cxy521/archive/2008/06/05/1214624.html

Verify the regular expression of the mobile phone number:/^(?:13\ D|15[89])-?\ D {5} (\ D {3}|\*{3}) $/

Regular Expression for phone number verification:/^(([0\+] \ D {2,3}-)?(0\ D {2,3})-) (\ D {7,8})(-(\ D {3,}))?$/

JSCode: Var pattern =/(^ ([0 \ +] \ D {2, 3 }-)? (0 \ D {2, 3})-) (\ D {7, 8}) (-(\ D {3 ,}))? $) | (^ 0 {0, 1} 1 [3 | 4 | 5 | 6 | 7 | 8 | 9] [0-9] {9} $ )/;

If (pattern. Test (VAL) {
return true;
}else {
return false;
}

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.