jquery validate异步验证时多参数传递
JSP代码:
<form role="form" class="add_form"> <input type="hidden" name="adminUserCategory.id" value="${adminUserCategory.id}" class="categoryId"> <div class="form-group input-name"> <label for="firstname" class="col-sm-2 control-label">名称</label> <div class="col-sm-10"> <input type="text" class="form-control" id="firstname" placeholder="请输入名称" name="adminUserCategory.name" value="${adminUserCategory.name}" style="width: 50%;float: left;"> <span class="err-class"></span> </div> </div> <div class="form-group input-description"> <label>描述</label> <textarea class="form-control" rows="5" name="adminUserCategory.Description">${adminUserCategory.description}</textarea> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default">保存</button> </div> </div> </form>
js中validate的rules的代码:
rules:{ "adminUserCategory.name":{ required:true, remote:{ type:"post",//数据请求方式 url: $('.domain_name').val()+"/Stat/checkUserCategoryNameExist.action",//异步验证路径 data:{ "adminUserCategory.name":function(){ return $("#firstname").val(); }, "adminUserCategory.id":function(){ return $(".categoryId").val();//没有这一行,获取不到数据 } }, dataType:"html", dataFilter:function(data,type){//AJAX异步返回数据 var flag = eval("("+data+")"); if(flag){ return true; }else{ return false; } } } } }
这样,adminUserCategory.name与adminUserCategory.id都能获取到界面的参数了
相关推荐
tztzyzyz 2020-07-20
ELEMENTS爱乐小超 2020-01-17
pengpengflyjhp 2020-05-31
tanyhuan 2020-04-18
81463166 2020-01-09
摄郎Elements 2014-04-10
zangdaiyang 2019-10-28
eroshn 2019-10-19
limengmeng00 2015-09-02
89387046 2017-11-08
sunshao0 2019-08-27
屈吉平Elements 2019-09-06