$("#form").validate({
invalidHandler: function(form, validator) {
$.each(validator.invalid,function(key,value){
alert(value);
return false;
}); //这里循环错误map,只报错第一个
},
errorPlacement:function(error, element) {
},
onkeyup: false,
onfocusout:false
});
改进一点,删除其他错误,执行默认的错误定位
$.validator.setDefaults({
invalidHandler: function(form, validator) {
$.each(validator.invalid,function(key,value){
tmpkey = key;
tmpval = value;
validator.invalid = {};
validator.invalid[tmpkey] = value;
alert(value);
return false;
});
},
errorPlacement:function(error, element) {
},
onkeyup: false,
onfocusout:false,
focusInvalid: true
});