定义:
var validator = jQuery("#form1").validate({ rules: { SignedOnIntegral: "required" }, messages: { SignedOnIntegral: "请输入签到奖励" }, showErrors: function(errorMap, errorList) { var msg = ""; $.each( errorList, function(i,v){ msg += (v.message+"\r\n"); }); if(msg!="") alert(msg); } });
调用:
var check = validator.checkForm(); validator.showErrors(); if (!check) { $("#form1").submit(); }