asp IsValidEmail 验证邮箱地址函数(email)
时间:2021-04-20 08:53:55|栏目:ASP代码|点击: 次
复制代码 代码如下:
'********************************************
'函数名: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
其它语言可以参考:
邮箱地址正则表达式验证代码合集脚本之家特别版
上一篇:SQL查询语句通配符与ACCESS模糊查询like的解决方法
栏 目:ASP代码
本文标题:asp IsValidEmail 验证邮箱地址函数(email)
本文地址:http://www.codeinn.net/misctech/104714.html