asp form 表單驗證函數(shù)
更新時間:2009年01月13日 12:13:53 作者:
比較不錯一些表單驗證函數(shù),大家可以參考下
'*************************************
'檢測是否只包含英文和數(shù)字
'*************************************
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
'*************************************
'檢測是否有效的數(shù)字
'*************************************
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
'檢測是否只包含英文和數(shù)字
'*************************************
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
'*************************************
'檢測是否有效的數(shù)字
'*************************************
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
您可能感興趣的文章:
- JS組件Form表單驗證神器BootstrapValidator
- AngularJS使用angular-formly進行表單驗證
- javascript Zifa FormValid 0.1表單驗證 代碼打包下載
- jquery表單驗證使用插件formValidator
- 基于Bootstrap+jQuery.validate實現(xiàn)Form表單驗證
- jQuery 表單驗證插件formValidation實現(xiàn)個性化錯誤提示
- jQuery formValidator表單驗證插件開源了 含API幫助、源碼、示例
- jQuery表單驗證插件formValidator(改進版)
- Validform+layer實現(xiàn)漂亮的表單驗證特效
- 基于javascript的Form表單驗證
相關(guān)文章
asp連接access、sql數(shù)據(jù)庫代碼及數(shù)據(jù)庫操作代碼
asp連接access、sql數(shù)據(jù)庫代碼及數(shù)據(jù)庫操作代碼,需要的朋友可以參考下2012-10-10用asp實現(xiàn)訪問遠程計算機上MDB access數(shù)據(jù)庫文件的方法
用asp實現(xiàn)訪問遠程計算機上MDB access數(shù)據(jù)庫文件的方法...2007-11-11ScriptHtml 函數(shù)之過濾html標記的asp代碼
ScriptHtml 函數(shù)之過濾html標記的asp代碼...2007-09-09asp控制xml數(shù)據(jù)庫的經(jīng)典代碼
本文為大家分享了六段經(jīng)典的asp控制xml數(shù)據(jù)庫代碼,感興趣的小伙伴們可以參考一下2015-09-09