自定义的验证方法Remote
2014-10-15 21:02
239 查看
jQuery.metadata.setType("attr", "validate"); var opts = null; var isValidationGroup = false; jQuery(document).ready(function () { InitRules(); if (isValidationGroup) { if (opts != undefined || opts != null) { jQuery("#form1").validate(jQuery.extend(opts, { onsubmit: false })); } else { jQuery("#form1").validate({ onsubmit: false }); } InitValidationGroup(); } else { if (opts != undefined || opts != null) { jQuery("#form1").validate(opts); } else { jQuery("#form1").validate(); } } }); function GetRemoteInfo1(postUrl, data) { var remote = { type: "POST", async: false, url: postUrl, dataType: "text", data: data, dataFilter: function(dataXML) { var result = new Object(); if (dataXML == "1") { result.Result = false; result.Msg="已存在,另换一个试试。"; return result; } else { result.Result =true; return result; } } }; return remote; } function InitRules() { var dataCode = { username: function () { return $("#txtUserName").val(); }, key:function(){ return "CheckSysAdminName"; } }; var remoteCode = GetRemoteInfo1('/Service/sysHandle.ashx', dataCode); opts = { rules: { txtUserName: { required: true, remote:remoteCode }, txtPass:{ required: true, minlength: 6 }, txtAgainPass:{ required: true, equalTo: "#txtPass" }, txtName:{ required: true } }, messages: { txtUserName: { required: "请输入账号。" }, txtPass:{ required: "请输入密码。", minlength: "至少输入6位的密码。" }, txtAgainPass:{ required: "请输入确认密码。", equalTo: "密码不一致。" }, txtName:{ required:"请输入姓名。" } } , success: function (label) { label.html(" ").attr("class", "success").siblings("label").remove(); }, errorPlacement: function (error, element) { $(element).next("span").find(".success").remove(); error.appendTo(element.next("span")); } } }
相关文章推荐
- jquery.validate remote 和 自定义验证方法
- jquery.validate remote 和 自定义验证方法
- jquery.validate remote 和 自定义验证方法
- jquery.validate remote 和 自定义验证方法
- jquery.validate remote 和 自定义验证方法
- jquery.validate remote 和 自定义验证方法
- 自定义的验证方法Remote
- jquery.validate remote 和 自定义验证方法
- dhl: jquery.validate验证框架_自定义方法
- jquery validate.addMethod 正则表达式 (自定义验证方法)
- MVC 两种自定义验证方法
- jquery.validate 自定义验证方法及validate相关参数
- jQuery Validation ,调用valid方法时,不验证remote
- ASP.NET生命周期中的验证以及身份验证模块(理解以后可以自定义验证方法)
- jquery.validate 自定义验证方法
- DWZ 框架remote 验证字段唯一性方法提交后台,如果是中文会显示成乱码问题
- jquery自定义验证方法
- jquery.validate:追加自定义验证方法
- Asp.net自定义验证控件CustomValidator 的使用方法
- jQuery validate 日期比较 自定义验证方法