There are many ways to
e-mail address validation. In the browser side, JS mailbox authentication can be detected through regular expressions.
| code is as follows |
&nbs P; |
|
function Isemail (email) {
return/^ (([A-z] |d| [!#$%& ' *+-/=?^_ ' {|} ~]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) +(. ([a-z]|d| [!#$%& ' *+-/=?^_ ' {|} ~]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) +)*)| ((x22) (((x20|x09) * (x0dx0a))? x20|x09) +)? ([x01-x08x0bx0cx0e-x1fx7f]|x21| [x23-x5b]| [x5d-x7e]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) | ([x01-x09x0bx0cx0d-x7f]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]))) * (((x20|x09) * (x0dx0a))? (x20|x09) +)? (x22))) @ (([a-z]|d| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) | ([a-z]|d| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) ([a-z]|d|-|.| _|~| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) * ([a-z]|d| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF])).) + ([a-z]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) | ([a-z]| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) ([a-z]|d|-|.| _|~| [U00A0-UD7FFUF900-UFDCFUFDF0-UFFEF]) * ([a-z]| [U00a0-ud7ffuf900-UFDCFUFDF0-UFFEF])) $/i.test (email);
}
or
Function Validateemail (elementvalue)
{
var emailpattern = /^[a-za-z0-9._]+[a-za-z0-9]+@[a-za-z0-9]+. [A-za-z] {2,4}$/;
return emailpattern.test (elementvalue);
}
Function checkemail (mail) {
return/^[w-]+ (. [ w-]+) *@ ([a-z0-9-]+. [ a-z0-9-]+) *?. [A-z] {2,6}| (d{1,3}.) {3}d{1,3}) (:d {4}) $/.test (mail);
} |
The call is simple:
| The code is as follows |
|
|
if (Isemail (' youremail@yourdomain.com ')) {Console.log (' www.111cn.net this are email is valid ');} View Code
|
If you are doing server-side validation. Like PHP, the easiest thing to do is:
| The code is as follows |
|
|
$a = '/([w._]{2,10}) @ (W{1,}). ([a-z]{2,4})/';
$b = ' 1412424545645454545454545k@qq.com ';
if (Preg_match ($a, $b)) {
echo "e-mail Legal";
}else{
echo "e-mail is illegal";
} |
You have to decide whether a whole string of strings matches is an assertion. such as ^ $
/^ ([w._]{2,10}) @ (W{1,}). ([a-z]{2,4}) $/
Note the head and tail plus ^ $