asp form 表单验证函数

来源:asp之家 时间:2011-04-04 11:10:00 

 

'************************************* 
'检测是否只包含英文和数字 
'************************************* 

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,form,表单验证
0
投稿

猜你喜欢

  • Bootstrap每天必学之响应式导航、轮播图

    2023-08-15 03:29:45
  • MySQL慢查询日志超详细总结

    2024-01-17 00:17:21
  • Oracle数据库及应用程序优化开发者网络Oracle

    2010-07-18 13:02:00
  • Python partial函数原理及用法解析

    2021-01-22 02:48:50
  • pandas 根据列的值选取所有行的示例

    2023-10-13 16:19:38
  • python 调用c语言函数的方法

    2023-12-11 17:24:21
  • sqlserver获取各种形式的时间

    2024-01-20 17:33:50
  • 如何在Vue单页面中进行业务数据的上报

    2024-04-26 17:42:13
  • MySql总弹出mySqlInstallerConsole窗口的解决方法

    2024-01-18 20:01:23
  • Vue 项目性能优化方案分享

    2024-05-10 14:20:36
  • 终端能到import模块 解决jupyter notebook无法导入的问题

    2022-11-19 19:26:29
  • 浅谈JavaScript 中的延迟加载属性模式

    2024-04-17 10:29:56
  • thinkPHP中配置的读取与C方法详解

    2023-11-14 17:12:35
  • js阻止移动端页面滚动的两种方法

    2023-08-04 17:36:12
  • Python绘图示例程序中的几个语法糖果你知道吗

    2021-01-18 17:15:25
  • Mysql自动备份与还原方法

    2024-01-15 03:19:32
  • Python中turtle库的使用实例

    2023-08-01 23:05:56
  • 五个小窍门帮你写出更好的CSS代码

    2009-06-09 12:42:00
  • SQL中distinct 和 row_number() over() 的区别及用法

    2024-01-12 20:16:35
  • MYSQL常用命令与实用技巧

    2024-01-22 05:22:25
  • asp之家 网络编程 m.aspxhome.com