Fuchangxi regular:
Copy codeThe Code is as follows:
/^ ([A-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + (. [a-zA-Z0-9 _-]) +/
It must start with one or more word characters or-, plus @, and then one or more word characters or -. Then there is a combination of "." And the word character and-. There can be one or more combinations.
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function isEmail (str ){
Var reg =/^ ([a-zA-Z0-9 _-]) + @ ([a-zA-Z0-9 _-]) + (. [a-zA-Z0-9 _-]) + /;
Return reg. test (str );
}
Var str = 'test @ hotmail.com ';
Document. write (isEmail (str) + '<br/> ');
Var str2 = 'test @ sima.vip.com ';
Document. write (isEmail (str2) + '<br/> ');
Var str3 = 'TE-st@qq.com.cn ';
Document. write (isEmail (str3) + '<br/> ');
Var str4 = 'te_st@sima.vip.com ';
Document. write (isEmail (str4) + '<br/> ');
Var str5 = 'TE .. _ st@sima.vip.com ';
Document. write (isEmail (str5) + '<br/> ');
</Script>
I am not familiar with the specific mailbox rules. It seems that this regular expression is relatively simple.
Count the mailbox @ prefix types
1. Pure numbers
For example: 123456@jb51.net
2. Pure letters
3. Mixed letters and numbers
4. vertex-based
For example: web.blue@jb51.net
5. Underline
For example: web_blue@jb51.net
6. Cable
For example: web-blue@jb51.net
The mailbox domain must have at least one "." And two words. Then, the last top-level domain must have at least two letters, the maximum? Take the domain name "name" as the standard. The maximum value is 4. Set the loose point to 5. ^_^.
Of course, the above is not possible: It starts or ends with "_" or "-" and contains special symbols.
Therefore, the regular expression I provide is as follows:
^ [A-Za-zd] + ([-_.] [A-Za-zd] +) * @ ([A-Za-zd] + [-.]) + [A-Za-zd] {2, 5} $
Copy codeThe Code is as follows:
<Script type = "text/javascript">
FChkMail = function (szMail ){
Var szReg =/^ [A-Za-zd] + ([-_.] [A-Za-zd] +) * @ ([A-Za-zd] + [-.]) + [A-Za-zd] {2, 5} $ /;
Var bChk = szReg. test (szMail );
Return bChk;
}
</Script>
<Input type = "text" id = "Mail" value = ""/>
<Input type = "button" value = "verify email address" onclick = "alert (fChkMail (document. getElementById ('mail'). value);"/>
<P> the email cannot start or end with-_. or other special characters </p>
<P> the email domain name ends with 2 ~ Five letters, such as cn, com, and name </p>