jquery verification of the mobile phone number of the mailbox ID card regular expression (including Hong Kong, Macao) _ Regular expression

Source: Internet
Author: User

Oneself to the regular verification also did not have the system to use, this time oneself makes a demo, all of a sudden put these all use, next time need to come directly to take.

The following code is validated in the page using jquery, but also in the background to verify that you can try, the same principle.

Directly on the code: note: (Some of the validation rules of course not only this article, perhaps there are other better, you can message exchange)

Mobile phone Number: (Mobile-telecom-China Unicom)

var tel = $ ("#PhoneNumber"). Val ();//Get input cell phone number
var yidongreg =/^ (134[012345678]\d{7}|1[34578][012356789]\d{8}) $/;    
var dianxinreg =/^1[3578][01379]\d{8}$/;
var liantongreg =/^1[34578][01256]\d{8}$/;
var reg =/^1[3|4|5|7|8]\d{9}$/;//This one can also be
if (yidongreg.test (tel) | | dianxinreg.test (TEL) | | liantongreg.test (TEL ))
{
}

Mailbox:  

var Emailvalue = $ ("#EmailUser"). Val ();//Get the mailbox entered
//var EMAILREG1 =/^\w+ ([-+.] \w+) *@ ("@") \w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$/;//This can also
var emailreg =/^\w+ ((-\w+) | ( \.\w+)) *\@ ("@") [A-za-z0-9]+ (\.| -) [a-za-z0-9]+) *\.    [a-za-z0-9]+$/;
if (Emailreg.test (emailvalue))
{
}

Id:

var Usercardvalue = $ ("#UserIDCard"). Val ()//Get input ID
var usercardreg =/(^\d{15}$) | ( ^\d{18}$) | (^\d{17} (\d|    X|X) $)/;
var taiwanreg=/^[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) | | Taiwanreg.test (usercardvalue) | | Xianggangreg.test (usercardvalue) | | AOMENREG.T EST (usercardvalue))
{
}

The above is a small series of jquery to introduce the verification of mobile phone number mailbox ID card regular expression (including Hong Kong, Macao), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.