汇总Javascript各种判断脚本(javascript经典例子)
2010-09-14 13:16:07 来源:WEB开发网' "Mobil" - 手机
' "Date" - 日期(格式:yyyy-mm-dd)
' "Email" - 电子邮件
' "Postalcode" - 邮政编码
' "Search" - 搜索关键字
' "Int" - 整数
'参数strng:要校验的字串
'返回值:校验结果,正确返回true,错误返回false
'********************************************
Function IsVerify(patrn,strng)
strng=Trim(strng)
Select Case patrn
Case "User" '用户名
patrn="^[a-z]{1}([a-z0-9]|[._]){2,19}$"
Case "Truename" '英文姓名
patrn="^[a-zA-Z]{1,30}$"
Case "Passwd" '密码
patrn="^(w){6,20}$"
Case "Tel" '电话/传真
patrn="^[+]{0,1}(d){1,3}[ ]?([-]?((d)|[ ]){1,12})+$"
Case "Mobil" '手机
patrn="^(d)+[-]?(d){6,12}$"
Case "Date" '日期(格式:yyyy-mm-dd)
patrn="^[12]{1}(d){3}[-][01]?(d){1}[-][0123]?(d){1}$"
Case "Email" '电子邮件
patrn="^((w)|[-]|[.])+@(((w)|[-])+[.])+[a-z]{2,4}$"
Case "Postalcode" '邮政编码
patrn="^[a-z0-9 ]{3,12}$"
Case "Search" '搜索关键字
patrn="^[^`~!@#$%^&*()+=|[]{}:;',.<>/?]{1}[^`~!@$%^&()+=|[]{}:;',.<>?]{0,19}$"
Case "Int" '整数
patrn="^[1-9]{1}[0-9]{0,6}$"
Case "Array"
patrn="^[0-9]{1}([0-9]|[,]){0,150}$"
End Select
Dim regEx
Dim Match
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Matches = regEx.test(strng)
IsVerify = Matches
Set regEx = Nothing
End Function
Tags:汇总 Javascript 各种
编辑录入:爽爽 [复制链接] [打 印]更多精彩
赞助商链接