Regular Expressions: Mailbox format and phone number (3-4-bit area code, 7-8-digit live number, 1-4 poorly transposition number)

Source: Internet
Author: User

<input type= "text" id= "UID" onblur= "Mail ()"/>//text box, to trigger the loss of focus when the mailbox or phone number format is correct, do not respond correctly, error output ("The user name of the mailbox or phone number format is incorrect" )
function Mail() {      varPatten2=NewREGEXP (/^[0-9| a-z|_]{1,17}[@][0-9| a-z]{1,3}. (COM) $/)//e-mail Regular expression  varPatten1 =NewREGEXP (/(\d{11}) |^ ((\d{7,8}) | ( \D{4}|\D{3})-(\d{7,8}) | (\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}) | (\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})) $/)//mobile phone number Regular expression (11-digit mobile phone number3-4-bit area code, 7-8-digit live number, 1-4 digits extension number)var Mail= document.getElementById ("UID").value; if(Patten1.test (Mail)|| Patten2.test (Mail))          {                        }         Else{alert ("The user name's mailbox or phone number is not formatted correctly"); } }

Regular Expressions: Mailbox format and phone number (3-4-bit area code, 7-8-digit live number, 1-4 poorly transposition number)

Related Article

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.