Fuchangxi's Regular:
Copy CodeThe code is as follows:
/^ ([0-9a-za-z\-_\.] +) @ ([0-9a-z]+\. [A-z] {2,3} (\. [A-z] {2})?) $/g
The start must be one or more word characters or--plus @, then one or more word characters or--. Then the point is "." and a combination of word characters and--can have one or more combinations.
Copy CodeThe code is as follows:
<script type= "Text/javascript" >
function Isemail (str) {
var reg =/^ ([a-za-z0-9_-]) [email protected] ([a-za-z0-9_-]) + (. [ A-za-z0-9_-]) +/;
return Reg.test (str);
}
var str = ' [email protected] ';
document.write (Isemail (str) + ' <br/> ');
var str2 = ' [email protected] ';
document.write (Isemail (str2) + ' <br/> ');
var str3 = ' [email protected] ';
document.write (Isemail (STR3) + ' <br/> ');
var str4 = ' [email protected] ';
document.write (Isemail (STR4) + ' <br/> ');
var str5 = ' [email protected] ';
document.write (Isemail (STR5) + ' <br/> ');
</script>
I don't quite understand the specific rules of the mailbox. It's easier to feel the regular.
Check out several types of mailbox @ prefixes
1, Pure Digital
For example: [email protected]
2, Pure Letter
3. Mixed alphanumeric numbers
4, with a point of
For example: [email protected]
5. Underlined
For example: [email protected]
6. With connecting Wire
For example: [email protected]
The mailbox domain has at least one "." And two words, then strictly point then the last top level domain to be at least 2 letters, Max? With the domain name "name" as the standard, then the largest is 4, relaxed point is set to 5 bar ^_^.
Of course the above impossible situation: with "_" or "-" beginning or end, containing the special symbol.
Therefore, the regular expression I gave is as follows:
/^ ([0-9a-za-z\-_\.] +) @ ([0-9a-z]+\. [A-z] {2,3} (\. [A-z] {2})?) $/g
Copy CodeThe code is as follows:
<script type= "Text/javascript" >
Fchkmail=function (Szmail) {
var szreg=/^ ([0-9a-za-z\-_\.] +) @ ([0-9a-z]+\. [A-z] {2,3} (\. [A-z] {2})?) $/g;
var bchk=szreg.test (Szmail);
return bchk;
}
</script>
<input type= "text" id= "Mail" value= ""/>
<input type= "button" value= "Verify the Mailbox Address" onclick= "alert (Fchkmail (document.getElementById (' Mail '). Value));"/>
<p> email cannot start and end with-_. and other special characters </p>
<p> the end of the mailbox domain name is 2~5 letters, such as CN, COM, name</p>
Original connection:
JavaScript Regular expression Verification e-mail address
Compare the regular expression of authentic verification mailbox JS code detailed
e-mail validation JavaScript code for regular expressions