Email address regular expression verification code collection script House Special Edition


Email address validation regular expression

Email address verification in decms

Copy codeThe code is as follows:
$email=”[email protected]”;
//Email format check

function CheckEmail($email)
return eregi(“^[0-9a-z][a-z0-9\._-]{1,}@[a-z0-9-]{1,}[a-z0-9]\.[a-z\.]{1,}[a-z]$”, $email);
echo CheckEmail($email);

Email address verification in phpcms

Copy codeThe code is as follows:

function is_email($email)
return strlen($email) > 6 && preg_match(“/^[\w\-\.][email protected][\w\-\.]+(\.\w+)+$/”, $email);
echo is_email($email);

Tested [email protected] This kind of email is not supported by checkemail, but is_ Email support, but such a mailbox is rarely used, so it is OK. You can choose according to your needs.

ASP judges whether the address format of e-mail box is correct
We can solve this problem in the following ways – but we can only judge whether the format of each e-mail address is valid, and we can’t guarantee that the address really exists.

The first method:

‘function name: chkmail
Function: mailbox format detection
‘parameter: Email – email address
‘return value: true, false
Public Function ChkMail(ByVal Email)
Dim Rep,Pmail : ChkMail = True : Set Rep = New RegExp
Rep.Pattern = “([\.a-zA-Z0-9_-]){2,10}@([a-zA-Z0-9_-]){2,10}(\.([a-zA-Z0-9]){2,}){1,4}$”
Pmail = Rep.Test(Email) : Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function
If ChkMail(“[email protected]”) = True Then
Response.Write “Format correct”
Response.Write “Format error”
End If

The second way is to use the following function to judge. It checks whether the email address contains “@” and whether the “.” is after “@”:

Public Function IsEmail(ByVal PString)
Dim Plt,Pgt : Plt = False : Pgt = False
For x = 2 To Len(PString) – 1
If Mid(PString,x,1) = “@” Then Plt = True
If Mid(PString,x,1) = “.” And Plt = True Then Pgt = True
If Plt = True And Pgt = True Then
IsEmail = True
IsEmail = False
End if
End Function

Copy codeThe code is as follows:
Function isemail(strng)
isemail = false
Dim regEx, Match
Set regEx = New RegExp
regEx.Pattern = “^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$”
regEx.IgnoreCase = True
Set Match = regEx.Execute(strng)
if match.count then isemail= true
End Function

JS email address verification code

[Ctrl + a all optional note: to introduce external JS, you need to refresh the page again]

In fact, a lot of code here is obtained from some well-known CMS systems, just like some good functions. Basically, in order to save time, you can refer to the source code of mature systems.
PHP can refer to dedecms, phpcms, etc
ASP can refer to the open source systems such as kesioncms, etc
JS can download JS from some websites to view it.

More form validation reference codes
JS common regex expression form verification code