jquery validate后台验证
给个比较详细的链接http://www.cnblogs.com/weiqt/articles/2013800.html
我主要说说如何通过remote来后台校验
贴出代码
js
 
$("#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: "字典名已存在" } });
后台部份代码
 
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";
 
                     
                    
                 
                    
                 
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号