Judge by JS
CopyCode The Code is as follows: function is_email (STR ){
P =/^ ([\ W \.-] +) @ ([a-zA-Z0-9-] +) (\. [A-Za-Z \.] +) $ /;
If (Str. Search (p) =-1 ){
Return false;
} Else {
Return true;
}
}
PHP-based judgment Copy codeThe Code is as follows: function is_email ($ email ){
$ Pattern = "/^ ([\ W \. -] +) @ ([a-zA-Z0-9-] + )(\. [A-Za-Z \.] +) $/I "; // contains letters, numbers, underscores (_), and dots. email of the name
If (preg_match ($ pattern, $ email, $ matches )){
Return true;
} Else {
Return false;
}
}
Use ASP to determine
Copy code The Code is as follows: function isvalidemail (email)
Dim names, name, I, C
Isvalidemail = true
Names = Split (email ,"@")
If ubound (names) <> 1 then
Isvalidemail = false
Exit Function
End if
For each name in names
If Len (name) <= 0 then
Isvalidemail = false
Exit Function
End if
For I = 1 to Len (name)
C = lcase (mid (name, I, 1 ))
If instr ("abcdefghijklmnopqrstuvwxyz _-.", c) <= 0 and not isnumeric (c) then
Isvalidemail = false
Exit Function
End if
Next
If left (name, 1) = "." Or right (name, 1) = "." Then
Isvalidemail = false
Exit Function
End if
Next
If instr (names (1), ".") <= 0 then
Isvalidemail = false
Exit Function
End if
I = Len (names (1)-faster Rev (names (1 ),".")
If I <> 2 and I <> 3 then
Isvalidemail = false
Exit Function
End if
If instr (email, "...")> 0 then
Isvalidemail = false
End if
End Function