jquery validate 多个复选框

89387046 2017-11-08

<div class="form-group">
<label class="col-sm-3 control-label" for="resids">对应资源:</label>
<div class="col-sm-8" id="type_list">

<input type="checkbox" id="qqq" value="glywh" name="resids" >

</div>
  <div class="col-sm-1"><span style="color:red;font-size:18px">*</span></div>
 </div>

//表单验证
function validataForm(){
 var e="<i class='fa fa-times-circle'></i> ";
 uias_validator = $("#form_UIASManager").validate({
  rules:{
   resids: {required: true},
   role_name: {required:true,maxlength:50}
  },
  messages:{
   resids:e+"请至少选择一项资源",
   role_name:{required:e+"请输入标题", maxlength:e+"不能超过50字符"}
  },
  errorPlacement: function (error, element){
   if (element.is(':radio') || element.is(':checkbox')) { 
    var eid = element.attr('name');
    error.appendTo(element.parent()); 
   }else{
    error.insertAfter(element);
   }
  },
  submitHandler: function(form) {
   $('#form_UIASManager').form('submit', {
    url : xxxxxx,
    type: "POST",
    success : function(data) {
    
    }
   });
  }
 });
}

相关推荐