ASP四个电子邮箱验证函数
ASP #正则 #邮箱 #函数2012-05-08 11:44
本文章提供的下面邮箱验证函数都是经过测试的各位可以放心的使用,有用正则表达式的也有不是的,好了下面我们来看看这几种asp教程 电子邮箱验证函数是不是你喜欢的风格吧。
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
'********************************************
'函数名: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
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
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正则表达式过滤html函数 2012/05/08
- ASP常用函数 2012/05/02
- ASP格式化时间日期函数 2012/04/30
- asp封装加密成dll文件 2012/04/27
- ASP连接Oracle数据库方法 2012/04/27
- ASP内容分页函数 2012/04/27
- asp无组件文件上传类 2012/04/27
- 防止ASP木马 2012/04/27
- asp操作Excel的类 2012/04/27
- asp防sql注入函数 2012/04/27