给个比较详细的链接http://www.cnblogs.com/weiqt/articles/2013800.html
我主要说说如何通过remote来后台校验
贴出代码
js
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
$("#addform").validate({ rules: { DictionaryName: { required: true, remote: { url: "AD_DATA_DICTIONARY.ashx?type=checkName&&stasts=Add", type: "post", dataType: "json", data: { DictionaryName: function () { return $("#DictionaryName").val(); } } } } }, messages: { DictionaryName: "字典名已存在" } });
后台部份代码
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
case "checkName": string status=context.Request["stasts"]; string dictionaryName=context.Request["dictionaryName"]; if (status == "Add") { if (dalADD.getNameCount(dictionaryName) > 0) context.Response.Write("false"); else context.Response.Write("true"); } else { if (dalADD.getNameCount(dictionaryName) > 1) context.Response.Write("false"); else context.Response.Write("true"); }; break;
看清楚后台返回的数据格式只能是字体串形式的"true"和"false";