输入验证类Validator
来源:ASP学习网 作者:Admin 时间:08-04-24 点击:
输入验证类Validator:
<%@Language="VBScript" CodePage="936"%>
<%
''Option Explicit
Class Validator
''*************************************************
'' Validator for ASP beta 3 服务器端脚本
'' code by 我佛山人
'' wfsr@cunite.com
''*************************************************
Private Re
Private ICodeName
Private ICodeSessionName
Public Property Let CodeName(ByVal PCodeName)
ICodeName = PCodeName
End Property
Public Property Get CodeName()
CodeName = ICodeName
End Property
Public Property Let CodeSessionName(ByVal PCodeSessionName)
ICodeSessionName = PCodeSessionName
End Property
Public Property Get CodeSessionName()
CodeSessionName = ICodeSessionName
End Property
Private Sub Class_Initialize()
Set Re = New RegExp
Re.IgnoreCase = True
Re.Global = True
Me.CodeName = "vCode"
Me.CodeSessionName = "vCode"
End Sub
Private Sub Class_Terminate()
Set Re = Nothing
End Sub
Public Function IsEmail(ByVal Str)
IsEmail = Test("^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*contentquot;, Str)
End Function
Public Function IsUrl(ByVal Str)
IsUrl = Test("^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\'':+!]*([^<>""])*contentquot;, Str)
End Function
Public Function IsNum(ByVal Str)
IsNum= Test("^\d+contentquot;, Str)
End Function
Public Function IsQQ(ByVal Str)
IsQQ = Test("^[1-9]\d{4,8}contentquot;, Str)
End Function
Public Function IsZip(ByVal Str)
IsZip = Test("^[1-9]\d{5}contentquot;, Str)
End Function
Public Function IsIdCard(ByVal Str)
IsIdCard = Test("^\d{15}(\d{2}[A-Za-z0-9])?contentquot;, Str)
End Function
Public Function IsChinese(ByVal Str)
IsChinese = Test("^[\u0391-\uFFE5]+contentquot;, Str)
End Function
Public Function IsEnglish(ByVal Str)
IsEnglish = Test("^[A-Za-z]+contentquot;, Str)
End Function
Public Function IsMobile(ByVal Str)
IsMobile = Test("^((\(\d{3}\))|(\d{3}\-))?13\d{9}contentquot;, Str)
End