Regular Expressions for JS mailbox verification and js mailbox regular expressions are collected on a daily basis.

Source: Internet
Author: User

Regular Expressions for JS mailbox verification and js mailbox regular expressions are collected on a daily basis.

Background, I also need to know a little about regular expressions, and then I tested them more :-)

The following email RegEx:

DASH: The dash domain name is the flat domain name mentioned by miannong. The flat domain name does not have much value because it is difficult to input, currently, there are few investors. According to DNS standards, domain names cannot be underlined.

Underline: some users like to use underline _ when registering a user name. This user name is very troublesome when logging on to the mailbox, and it is inconvenient for people who send emails to you.

The second-level domain name mailbox is basically wiped out. This buddy's regular expression can be underlined to expand the scope, but the problem is not big, mainly to prompt the user.

Com.cn domain name support :( \. [a-zA-Z0-9-] {2, 3}) {1} com.cn

--------------------------------------------------------------
// Emailpreg =/^ [A-Za-zd] + ([-_.] [A-Za-zd] +) * @ ([A-Za-zd] + [-.]) + [A-Za-zd] {2, 5} $/; // the email address of the QQ number cannot be verified.
Emailpreg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + ((\. [a-zA-Z0-9 _-] {2, 3}) {1, 2}) $/; // The dfdfd1212@dfdfd.abc.cn is a secondary mailbox. Abc@12df1.com.cn
Emailpreg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9-]) + ((\. [a-zA-Z0-9-] {2, 3}) {1, 2}) $/; // The domain name is not allowed to have underscores, remove the underline, this is the last regular. The first letter cannot be an underscore. In this case, the regular expression will be extended... the user is not a sb, but it just serves as a prompt. Don't make it complicated. So far.
<Dd> <input id = "2" rel = "Mailbox" res = '2' type = "text" class = "item-edit-txt" name = "2" value = "<{$ user. email >>></dd>
} Else if ($ (this). attr ('res') = '2 '&&! Emailpreg. test ($ (this). val () {// the user interface logged on from QQ cannot obtain the email address. Open it and enter it.
Certificate (this).css ("border", "1px solid # f00 ");
$ ("#" + $ (This). attr ('res') + 'span '). remove ();
$ ("#" + $ (This ). attr ('res ')). after ("<span id =" + $ (this ). attr ('res') + 'span '+ "> <br/>" + $ (this ). attr ("rel") + "Incorrect format </span> ");
$ (This). focus ();
Res = false;
Return false;

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

The JavaScript form verifies the email and determines whether an input is an email address using a regular expression.

// Check email mailbox function isEmail (str) {var reg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + ((\. [a-zA-Z0-9 _-] {2, 3}) {1, 2}) $/; return reg. test (str );}

The above content is a small series for you to collect regular expressions for JS mailbox verification on a daily basis, I hope you like it.

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.