最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用ASP判断Email地址是否有效
时间:2022-06-30 10:07:09 编辑:袖梨 来源:一聚教程网
用ASP判断Email地址是否有效
2000-03-23・ 王俊・CPCW
在用ASP编写页面时,如果涉及到邮件发送,一般会要求输入Email地址。错误的Email地址往往带来许多不必要的麻烦,用下面的函数IsValidEmail就能判断出一个Email地址是否有效。
函数源代码:
<%
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
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
%>
用法举例:
IsValidEmail("[email protected]") 返回Ture
IsValidEmail("[email protected]") 返回Ture
IsValidEmail("myemail263.net") 返回False
IsValidEmail("my_263_email@263) 返回False
请注意,函数只是判断Email地址格式是否有效,但并不能检查该地址是否确实存在。
2000-03-23・ 王俊・CPCW
在用ASP编写页面时,如果涉及到邮件发送,一般会要求输入Email地址。错误的Email地址往往带来许多不必要的麻烦,用下面的函数IsValidEmail就能判断出一个Email地址是否有效。
函数源代码:
<%
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
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
%>
用法举例:
IsValidEmail("[email protected]") 返回Ture
IsValidEmail("[email protected]") 返回Ture
IsValidEmail("myemail263.net") 返回False
IsValidEmail("my_263_email@263) 返回False
请注意,函数只是判断Email地址格式是否有效,但并不能检查该地址是否确实存在。
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21