Method 1:
<%
Function IsValidEmail (Email)
ValidFlag = False
If (Email <> "") And (InStr (1, Email, "@")> 0) And (InStr (1, Email, ".")> 0) Then
AtCount = 0
SpecialFlag = False
For atLoop = 1 To Len (Email)
AtChr = Mid (Email, atLoop, 1)
If atChr = "@" Then atCount = atCount + 1
If (atChr> = Chr (32) And (atChr <= Chr (44) Then SpecialFlag = True
If (atChr = Chr (47) Or (atChr = Chr (96) Or (atChr> = Chr (123) Then SpecialFlag = True
If (atChr> = Chr (58) And (atChr <= Chr (63) Then SpecialFlag = True
If (atChr> = Chr (91) And (atChr <= Chr (94) Then SpecialFlag = True
Next
If (atCount = 1) And (SpecialFlag = False) Then
BadFlag = False
TAry1 = Split (Email ,"@")
UserName = tAry1 (0)
DomainName = tAry1 (1)
If (UserName = "") Or (DomainName = "") Then BadFlag = True
If Mid (DomainName, 1, 1) = "." then BadFlag = True
If Mid (DomainName, Len (DomainName), 1) = "." then BadFlag = True
ValidFlag = True
'The format is correct and true is returned.
End If
End If
If BadFlag = True Then ValidFlag = False
'If the format is incorrect, False is returned.
IsValidEmail = ValidFlag
End Function
%>
Method 2:
<%
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
%>
The third method is to use the following function for judgment. It checks whether the email address contains "@" and whether "." Is after:
Function isEmail (pInString)
LAt = False
LDot = false
For x = 2 to len (pInstring)-1
If mid (pInString, x, 1) = "@" then lAt = True
If mid (pInString, x, 1) = "." and lAt = True then lDot = True
Next
If lAt = True and lDot = True then
IsEmail = True
Else
IsEmail = False
End if
End function
[1]