asp服务器端的验证类


所属类别:Asp

文章作者:未知

特别推荐:免费发布信息 承包关键词~~抢爆了!HOT!


<%'================================================================='Version:1.0'Data=2004-7-5'Script Written By: 幸福.net(Nicholas)'=================================================================='CopyRight By: 九州信息网络有限公司'web: www.21hb.com'email:nicholas_cheung@21cn.com'==================================================================Class Cls_ValidatorRem =======================验证类说明==============================Rem=作用:对于输入数据的验证Rem=例:set va=new Cls_ValidatorRem= va.Requirefield request("asd"),"错误请重新输入"Rem=Rem=Rem==================================================================Private Validator1,Validator2Public Property Get Validator() '定义属性:验证Validator=Validator1End PropertyPublic Property Let Validator(Validator2)Validator1=Validator2End PropertyPublic Function Requirefield(requestfieled,errorname)'确保用户不跳输的方法 errorname是输入的字符串 requestname为错误信息if requestfieled="" thenRequirefield=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseRequirefield=trueValidator1=trueend ifEnd FunctionPublic Function CompareValidator(requestfieled1,requestfieled2,operator,errorname)'比较验证的方法 requestfieled1,requestfieled2为输入字符串 operator再比较符 errorname为错误信息Select case operator '判断比较运算符Case ">"if (not requestfieled1>requestfieled2) thenCompareValidator=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseCompareValidator=TrueValidator1=trueend ifCase "<"if (not requestfieled1alert('"&errorname&"');history.back()")Response.End()elseCompareValidator=TrueValidator1=trueend if Case "="if (not requestfieled1=requestfieled2) thenCompareValidator=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseCompareValidator=TrueValidator1=trueend if Case ">="if (not requestfieled1>=requestfieled2) thenCompareValidator=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseCompareValidator=TrueValidator1=trueend if Case "<="if (not requestfieled1<=requestfieled2) thenCompareValidator=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseCompareValidator=TrueValidator1=trueend ifCase "<>"if requestfieled1=requestfieled2 thenCompareValidator=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")response.end()elseCompareValidator=TrueValidator1=trueend ifend SelectEnd FunctionPublic Function isnum(requestfieled,errorname)'判断是否为数字。requestfieled为输入字符串 errorname 为错误信息if (not IsNumeric(requestfieled) )thenisnum=falseValidator1=falseValidator1=trueResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseisnum=trueend ifEnd FunctionPublic Function legstr(requestfieled,num,errorname)'限制字符串的个数 requestfieled为输入字符串 num为限制的字数 ,errorname为错误信息numrequestfieled=cint(Len(requestfieled)) '获取字符串的个数if numrequestfieled>num thenlegstr=falseValidator1=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elselegstr=trueValidator1=trueend ifEnd FunctionPublic Function isemail(requestfieled,errorname)'判断是否为电子邮箱格式 requestfieled为输入值 errorname为错误信息set re=new RegExpre.Pattern=".*@.{2,}\..{2,}"re.Global = Truere.IgnoreCase = Truere.MultiLine = Trueif (not re.test(requestfieled)) thenisemail=falseValidator=falseResponse.Write("alert('"&errorname&"');history.back()")Response.End()elseisemail=trueend ifEnd FunctionEnd Class%>关闭本页

相关信息

· c

· 学会选择功能稳定的网吧路由器

· 未雨绸缪:网络入侵监测系统IDS

· 病毒的本质








....

63364 83933