asp验证电子邮件地址

时间:2009-03-26    点击:1675   
<%
'验证Str是否是合法的电子邮件地址
Public Function ValidEmail(Str)
    Dim StrArray, TempStr, I, TempChar
    ValidEmail = True
    StrArray = Split(Str, "@")
    If UBound(StrArray) <> 1 Then
'如果不含有"@"或者含有多个"@",未能通过验证
        ValidEmail = False
        Exit Function
    End If
    For Each TempStr in StrArray
        If Len(TempStr) <= 0 Then
     '如果数组中的元素为空字符串,未能通过验证
            ValidEmail = False
            Exit Function
        End If
        For I = 1 to Len(TempStr)
            TempChar = LCase(Mid(TempStr, I, 1))
            If InStr("abcdefghijklmnopqrstuvwxyz_-.", TempChar) <= 0 And Not IsNumeric(TempChar) Then
                '如果不是字母、数字以及"_"、"-"、"."等特殊字符,则为非法字符,未能通过验证
ValidEmail = False
                Exit Function
            End If
        Next
        If Left(TempStr, 1) = "." Or Right(TempStr, 1) = "." Then
'如果"."在字符串的最前或最后,未能通过验证
ValidEmail = False
            Exit Function
        End If
    Next
    If InStr(StrArray(1), ".") <= 0 Then
        '如果@后没有".",未能通过验证
ValidEmail = False
        Exit Function
    End If
    I = Len(StrArray(1)) - InStrRev(StrArray(1), ".")
    If I <> 2 And I <> 3 Then
      '如果"."位置错误,未能通过验证
        ValidEmail = False
        Exit Function
    End If
    If InStr(Str, "..") > 0 Then
'如果含有"..",未能通过验证
        ValidEmail = False
    End If
End Function
%>
用ASP提供的浏览器性能组件来辨别客户浏览器
asp使用Counters组件实现网站访问人数统计
如何在ASP中引用类
asp组件安装
asp不刷新页面筛选数据库中的数据
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 All Rights Reserved