asp form 表单验证函数

所属分类: 网络编程 / ASP编程 阅读数: 1151
收藏 0 赞 0 分享
'*************************************
'检测是否只包含英文和数字
'*************************************

Function IsvalidValue(ArrayN, Str)
IsvalidValue = False
Dim GName
For Each GName in ArrayN
If Str = GName Then
IsvalidValue = True
Exit For
End If
Next
End Function

'*************************************
'检测是否有效的数字
'*************************************

Function IsInteger(Para)
IsInteger = False
If Not (IsNull(Para) Or Trim(Para) = "" Or Not IsNumeric(Para)) Then
IsInteger = True
End If
End Function

'*************************************
'用户名检测
'*************************************

Function IsValidUserName(byVal UserName)
Dim i, c
Dim VUserName
IsValidUserName = True
For i = 1 To Len(UserName)
c = LCase(Mid(UserName, i, 1))
If InStr("$!<>?#^%@~`&*();:+='""     ", c) > 0 Then
IsValidUserName = False
Exit Function
End If
Next
For Each VUserName in Register_UserName
If UserName = VUserName Then
IsValidUserName = False
Exit For
End If
Next
End Function

'*************************************
'检测是否有效的E-mail地址
'*************************************

Function IsValidEmail(Email)
Dim names, Name, i, c
IsValidEmail = True
Names = Split(email, "@")
If UBound(names) <> 1 Then
IsValidEmail = False
Exit Function
End If
For Each Name IN names
If Len(Name) <= 0 Then
IsValidEmail = False
Exit Function
End If
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
End If
Next
If Left(Name, 1) = "." Or Right(Name, 1) = "." Then
IsValidEmail = False
Exit Function
End If
Next
If InStr(names(1), ".") <= 0 Then
IsValidEmail = False
Exit Function
End If
i = Len(names(1)) - InStrRev(names(1), ".")
If i <> 2 And i <> 3 Then
IsValidEmail = False
Exit Function
End If
If InStr(email, "..") > 0 Then
IsValidEmail = False
End If
End Function
更多精彩内容其他人还在看

ASP 指南

ASP 指南
收藏 0 赞 0 分享

改进 ASP 的字符串处理性能

改进 ASP 的字符串处理性能
收藏 0 赞 0 分享

pjblog2的参数第1/2页

pjblog2的参数
收藏 0 赞 0 分享

ASP智能搜索的实现

ASP智能搜索的实现
收藏 0 赞 0 分享

网站生成静态页面攻略2:数据采集

网站生成静态页面攻略2:数据采集
收藏 0 赞 0 分享

网站生成静态页面攻略3:防采集策略

网站生成静态页面攻略3:防采集策略
收藏 0 赞 0 分享

网站生成静态页面攻略4:防采集而不防搜索引擎策略

网站生成静态页面攻略4:防采集而不防搜索引擎策略
收藏 0 赞 0 分享

简单分页函数一 常用

简单分页函数一 常用
收藏 0 赞 0 分享

asp最常用的分页函数

asp最常用的分页函数
收藏 0 赞 0 分享

LINE9的目录浏览源程序

LINE9的目录浏览源程序
收藏 0 赞 0 分享
查看更多