the regular of the Fuchangxi:
Copy Code code as follows:
/^ ([a-za-z0-9_-]) +@ ([a-za-z0-9_-]) + (. [ A-za-z0-9_-]) +/
The beginning must be one or more word characters or--, plus @, then one or more word characters or--. And then the dot "." and a combination of word characters and-can have one or more combinations.
Copy Code code 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 don't know the exact rules of the mailbox. It's easier to feel this way.
count the types of mailbox @ prefixes
1, Pure Digital
For example: 123456@jb51.net
2, Pure Letter
3. Alphanumeric mixing
4, with a dot of
For example: web.blue@jb51.net
5, underlined
For example: web_blue@jb51.net
6, with connecting wiring
For example: web-blue@jb51.net
The mailbox field has at least one "." and two words, and then the last top-level domain should be at least 2 letters, Max? The domain name "name" as the subject, then the biggest is 4, loose point set to 5 bar ^_^.
Of course the above impossible situation: with "_" or "-" to the beginning or end, containing special symbols.
Therefore, the regular expressions I give are as follows:
^[a-za-zd]+ ([-_.] [a-za-zd]+) *@ ([a-za-zd]+[-.]) +[a-za-zd]{2,5}$
Copy Code code 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 Mailbox Address "onclick=" alert (Fchkmail (document.getElementById (' Mail '). Value); "/>
<p> mailboxes cannot start and end with-_. and other special characters </p>
<p> mailbox domain names end with 2~5 letters, such as CN, COM, name</p>