I have following form with jquery validate.
When I submit the form without entering any values, it shows error messages. But when I enter value in “Amount” textbox, both the error messages are disappeared.
Also, after that, when I clear value in the Amount textbox, only the "Amount" error message is displayed until I click the button.
How to fix this?
Fiddle
jQuery Code
$("#formAddPayment").validate({
rules: {
"ddlModeOfPayment": {
required: true
},
"txtAmount": {
required: true
}
},
messages: {
"ddlModeOfPayment": {
required: "Please select Mode of Payment."
},
"txtAmount": {
required: "Please enter Amount."
}
},
showErrors: function (errorMap, errorList) {
var errorListResult = $.map(errorList, function(error){
return "<li>" + error.message+ "</li>";
});
$('#errorSummaryList').html(errorListResult.join(''))
$('#errorSummaryList').fadeIn('fast');
//Show error adjuscent to control also
//this.defaultShowErrors();
},
submitHandler: function (form) {
return false;
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…