Email address verification regular expression
Email address verification in dedecms
<?php
$email="test@";
//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
function is_email($email)
{
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
echo is_email($email);
?>
After testing, checkEmail like a@ does not support it but is_email, but few people use it for such mailboxes, so it is also OK. You can choose according to your needs.
asp Determine whether the address format of the email email address is correct
We can solve this problem by using the following methods - but we can only determine whether the format of each email address is valid, and it does not guarantee that the address does exist.
The first method:
<%
'****************************************************
'Function name: ChkMail
'Function: Email format detection
'Article: Email ----Email address
'Return value: True is correct, False is incorrect
'****************************************************
Public Function ChkMail(ByVal Email)
Dim Rep,Pmail : ChkMail = True : Set Rep = New RegExp
= "([\.a-zA-Z0-9_-]){2,10}@([a-zA-Z0-9_-]){2,10}(\.([a-zA-Z0-9]){2,}){1,4}$"
Pmail = (Email) : Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function
%>
use:
If ChkMail("ls535427@") = True Then
"Correct format"
Else
"The format is wrong"
End If
The second method is to use the following function to make judgments. It checks if the email address contains "@", and if "." 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
Next
If Plt = True And Pgt = True Then
IsEmail = True
Else
IsEmail = False
End if
End Function
%>
<%
Function isemail(strng)
isemail = false
Dim regEx, Match
Set regEx = New RegExp
= "^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"
= True
Set Match = (strng)
if then isemail= true
End Function
%>
js email address verification code
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
In fact, many of the codes here are obtained from some well-known cms systems, just like some relatively good functions. Basically, in order to save time, you can refer to the source code of mature systems.
For php, please refer to dedecms phpcms, etc.
Asp You can refer to kesioncms open source systems such as Dongyi
js can download js from some websites to view more js.
More form verification reference codes
js commonly used regex expression form verification code
Email address verification in dedecms
Copy the codeThe code is as follows:
<?php
$email="test@";
//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 the codeThe code is as follows:
function is_email($email)
{
return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email);
}
echo is_email($email);
?>
After testing, checkEmail like a@ does not support it but is_email, but few people use it for such mailboxes, so it is also OK. You can choose according to your needs.
asp Determine whether the address format of the email email address is correct
We can solve this problem by using the following methods - but we can only determine whether the format of each email address is valid, and it does not guarantee that the address does exist.
The first method:
<%
'****************************************************
'Function name: ChkMail
'Function: Email format detection
'Article: Email ----Email address
'Return value: True is correct, False is incorrect
'****************************************************
Public Function ChkMail(ByVal Email)
Dim Rep,Pmail : ChkMail = True : Set Rep = New RegExp
= "([\.a-zA-Z0-9_-]){2,10}@([a-zA-Z0-9_-]){2,10}(\.([a-zA-Z0-9]){2,}){1,4}$"
Pmail = (Email) : Set Rep = Nothing
If Not Pmail Then ChkMail = False
End Function
%>
use:
If ChkMail("ls535427@") = True Then
"Correct format"
Else
"The format is wrong"
End If
The second method is to use the following function to make judgments. It checks if the email address contains "@", and if "." 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
Next
If Plt = True And Pgt = True Then
IsEmail = True
Else
IsEmail = False
End if
End Function
%>
Copy the codeThe code is as follows:
<%
Function isemail(strng)
isemail = false
Dim regEx, Match
Set regEx = New RegExp
= "^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"
= True
Set Match = (strng)
if then isemail= true
End Function
%>
js email address verification code
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
In fact, many of the codes here are obtained from some well-known cms systems, just like some relatively good functions. Basically, in order to save time, you can refer to the source code of mature systems.
For php, please refer to dedecms phpcms, etc.
Asp You can refer to kesioncms open source systems such as Dongyi
js can download js from some websites to view more js.
More form verification reference codes
js commonly used regex expression form verification code