清空之前驗證錯誤的訊息
$.fn.clearValidation = function () {
var validator = $(this).validate();
$('[name]', this).each(function () {
validator.successList.push(this);
validator.showErrors();
});
validator.resetForm();
validator.reset();
};
移除之前的驗證結果
$("#my-phone-number-element").removeData("previousValue");
$("#my-phone-number-element").valid();
移至錯誤的欄位
$("#form").validate({
onfocusout: false,
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
validator.errorList[0].element.focus();
}
}
});
參考連結