日期:2014-05-16 浏览次数:20439 次
/* 名称命名规则说明 * 首字母大写,非常少用的尽可能用Custom * 注:如果添加了方法形式的,记得在Validate中的case中补上 * -------------------- * zxh:增加了默认的msg提示,以大量减少页面上的msg属性 * 详细使用,请参考附件的帮助文档!! */ __Validator__ = { Account:{"value":/^[A-Za-z]{1}([A-Za-z0-9\-_]+)?$/, "msg":"只能以英文字母开头,允许英文字母、数字、中下划线"}, Chinese:{"value":/^[\u0391-\uFFE5]+$/, "msg":"只允许中文"}, Currency:{"value":/^\d+(\.\d+)?$/, "msg":""}, Email:{"value":/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, "msg":"请输入正确的E-mail,如test@test.com"}, English:{"value":/^[A-Za-z]+$/, "msg":"只允许英文字母"}, IdCard:{"value":/^\d{15}(\d{2}[A-Za-z0-9\*])?$/, "msg":"只能输入18位的身份证号码"}, Mobile:{"value":/^1[358]{1}\d{9}$/, "msg":"只能输入格式为以13,15,18开头的11位数字的手机号码"}, MobilePhone:{"value":/^((0\d{2,3}(\d{6,15}))|(1\d{10}))$/, "msg":"直接输入手机号码或带区号的其他电话号码(只限数字)"}, Number:{"value":/^\d+$/, "msg":"请输入数值"}, UnSafe:{"value":/^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/, "msg":""}, Phone:{"value":/^((\(\d{3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}([\-0-9]+)?[^\D]{1}$/, "msg":"请输入正确电话号码"}, QQ:{"value":/^[1-9]\d{4,9}$/, "msg":"请输入5-10位数的纯数字"}, UnQueryString:{"value":/[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]+/, "msg":"不安全字符串"}, Require:{"value":/.+/, "msg":"不能为空"}, VRequire:{"value":/\S+/, "msg":"不能为空,必须输入任意非空字符"}, Url:{"value":/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/, "msg":"请输入正确的URL地址"}, Trim:{"value":/^[^\s]{1}(.+)?[^\s]{1}$/, "msg":"不能为空,并且前后不能有空格"}, Zip:{"value":/^[1-9]\d{5}$/, "msg":"邮政编码不存在"}, NumLength:{"value":/^[1-9]\d{3}$/, "msg":"长度小于5"}, Double:{"value":"this.IsNumber(value, true)", "msg":"请输入数字"}, PlusDouble:{"value":"this.IsPlusNumber(value)", "msg":"请输入正数"}, MinusDouble:{"value":"this.IsMinusNumber(value)", "msg":"请输入负数"}, Integer:{"value":"this.IsInteger(value)", "msg":"请输入整数"}, PlusInteger:{"value":"this.IsPlusInteger(value)", "msg":"请输入正整数"}, MinusInteger:{"value":"this.IsMinusInteger(value)", "msg":"请输入负整数"}, Compare:{"value":"this.compare(value,getAttribute('operator'),getAttribute('to'))", "msg":""}, Custom:{"value":"this.Exec(value, getAttribute('regexp'))", "msg":""}, Date:{"value":"this.IsDate(value, getAttribute('min'), getAttribute('format'))", "msg":"格式不正确"}, Filename:{"value":"this.IsFilename(value)", "msg":"文件名不能为空,且不能包含下列字符 \\ \/ \: \* \? \" < >"}, Filter:{"value":"this.DoFilter(value, getAttribute('accept'))", "msg":""}, Group:{"value":"this.MustChecked(getAttribute('name'), getAttribute('min'), getAttribute('max'))", "msg":""}, Limit:{"value":"this.Limit(value.length,getAttribute('min'), getAttribute('max'))", "msg":""}, LimitB:{"value":"this.Limit(this.LenB(value), getAttribute('min'), getAttribute('max'))", "msg":""}, Repeat:{"value":"value == document.getElementById(getAttribute('to')).value", "msg":"重复输入不一致"}, Range:{"value":"getAttribute('min') < (value|0) && (value|0) < getAttribute('max')", "msg":""}, SafeQueryString:{"value":"this.IsSafeQuery(value)", "msg":"含有不安全字符串,如\"!@#$%^&*'等等"}, SafeString:{"value":"this.IsSafe(value)", "msg":"密码不符合安全规则"}, ErrorItem:[document.forms[0]], ErrorMessage:["\u4ee5\u4e0b\u539f\u56e0\u5bfc\u81f4\u63d0\u4ea4\u5931\u8d25\uff1a\t\t\t\t"],//ErrorMessage:["以下原因导致提交失败:\t\t\t\t"], Validate:function(formID, mode) { var theForm = document.getElementById(formID); var obj = theForm || event.srcElement; var count = obj.elements.length; this.ErrorMessage.length = 1; this.ErrorItem.length = 1; this.ErrorItem[0] = obj; for(var i = 0; i < count; i++) { with(obj.elements[i]) { var _dataType = getAttribute("dataType"); if(typeof (_dataType) == "object" || typeof (this[_dataType]) == "undefined") { continue; } this.ClearState(obj.elements[i]); if(getAttribute("require") == "false" && value == "") { continue; } switch(_dataType) { case "Double": case "PlusDouble": case