email邮箱检测是最常用的一种检测,我们一般先用JS在客户端做判断,提交数据后服务器端也要做email合法性检测,编程之家跟大家分享:ASP邮箱email格式合法验证检测代码大全。
ASP检测email之用字符串查找的方法
'********************************************
'函数名:IsValidEmail
'作 用:检查Email地址合法性
'参 数:email ----要检查的Email地址
'返回值:True ----Email地址合法
' False ----Email地址不合法
'********************************************
Public Function IsValidEmail(Email)
Dim names, name, I, c
IsValidEmail = True
names = Split(Email, "@")
If UBound(names) <> 1 Then IsValidEmail = False: Exit Function
For Each name In names
If Len(name) <= 0 Then IsValidEmail = False:Exit Function
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
Next
If Left(name, 1) = "." Or Right(name, 1) = "." Then IsValidEmail = False:Exit Function
Next
If InStr(names(1), ".") <= 0 Then IsValidEmail = False:Exit Function
I = Len(names(1)) - InStrRev(names(1), ".")
If I <> 2 And I <> 3 Then IsValidEmail = False:Exit Function
If InStr(Email, "..") > 0 Then IsValidEmail = False
End Function
ASP检测email之正则表达式验证方法一
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
ASP检测email之正则表达式验证方法二
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
ASP检测email之正则表达式验证方法三
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。