Regular Expression (including Hong Kong, Macao and Taiwan(China)) and jQuery Regular Expression for verifying mobile phone number email ID card

Source: Internet
Author: User

Regular Expression (including Hong Kong, Macao and Taiwan(China)) and jQuery Regular Expression for verifying mobile phone number email ID card

I have never used the regular expression verification system. I made a demo this time and used it all at once. I will take it directly next time.

The following code uses JQuery for verification on the page, and is also used for verification in the background. You can try the same principle.

Go directly to the Code: Note: (some verification rules are not only in this article, but may also be better. You can leave a message)

Mobile phone number: (mobile-China Telecom-China Unicom)

Var tel = $ ("# PhoneNumber "). val (); // get the entered mobile phone number var yidongreg =/^ (134 [012345678] \ d {7} | 1 [34578] [012356789] \ d {8 }) $/; var dianxinreg =/^ 1 [3578] [01379] \ d {8} $ /; var liw.greg =/^ 1 [34578] [01256] \ d {8} $ /; // var reg =/^ 1 [3 | 4 | 5 | 7 | 8] \ d {9} $/; // This type can also be if (yidongreg. test (tel) | dianxinreg. test (tel) | liw.greg. test (tel )){}

Email:  

Var emailvalue = $ ("# EmailUser "). val (); // get the entered email address // var emailreg1 =/^ \ w + ([-+.] \ w +) * @ ("@") \ w + ([-.] \ w + )*\. \ w + ([-.] \ w +) * $/; // This can also be var emailreg =/^ \ w + (-\ w +) | (\. \ w +) * \ @ ("@") [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $/; if (emailreg. test (emailvalue )){}

ID card:

Var userCardvalue = $ ("# UserIDCard "). val (); // obtain the input ID card var userCardreg =/(^ \ d {15} $) | (^ \ d {18} $) | (^ \ d {17} (\ d | X | x) $)/; var =/^ [A-Z] [0-9] {9} $ /; var xianggangreg =/^ [A-Z] [0-9] {6} \ ([0-9A] \) $ /; var aomenreg =/^ [157] [0-9] {6} \ ([0-9] \) $/; if (userCardreg. test (userCardvalue) | (userCardvalue) | xianggangreg. test (userCardvalue) | aomenreg. t est (userCardvalue )){}

The above is the regular expression (including Hong Kong, Macao and Taiwan(China)) for jQuery to verify the mobile phone number email id card. I hope it will help you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!


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.