Jquery.validate 验证

$(document).ready(function(){
 $("#nsrsbh").attr("disabled",true);
 $("input[name=wfxwfsrq]").attr("disabled",true);
 $("input[name=wfxwfsrz]").attr("disabled",true);
 $("input[name=fxrq]").attr("disabled",true);
 var validator = $("#form_data").validate({
      rules: {
            blyyzzsj:"required",
            yqblsj:  "required", 
            wfcw:    "required",
            ffsd:    "required",
            zje:     {required:true,number:true},
            zsjsk:   "required",
            jtqx:    "required",
            dbsk:    {required:true,number:true},
            wspzzl:  "required",
            fpfs:    {required:true,digits:true},
            ywfss:   "required"
    },
   messages:{
      blyyzzsj:"请填写办理营业执照时间",
            yqblsj:  "请填写逾期办理时间", 
            wfcw:    "请填写违法财物",
            ffsd:    "请填写非法所得",
            zje:     {required:"请填写总金额",number:"请填写数字类型数据!"},
            zsjsk:   "请填写涉及税款",
            jtqx:    "请填写具体情形",
            dbsk:    {required:"请填写担保税款",number:"请填写数字类型数据!"},
            wspzzl:  "请填写完税凭证种类",
            fpfs:    {required:"请填写发票份数",digits:"请填写整数类型数据!"},
            ywfss:   "请填写原违法事实"
    },
    errorElement: "em", //可以用其他标签,记住把样式也对应修改
    success: function(label) {
     //label指向上面那个错误提示信息标签em
     label.text(" ")    //清空错误提示消息
      .addClass("success"); //加上自定义的success类
      }
   });

  $("#save").click(function() {
    if(validator.form()){ //若验证通过,则调用保存/修改方法
      alert("success");
    }
  });
    
});

你可能感兴趣的:(jquery)