I never want any error messages to appear on the view (I am using toastr to display errors generated by knockout validation). In my code, I am using: insertMessages: false. That suppresses errors UNLESS the user enters data in a required field, removes that data, and then tabs out of the control. I can't figure out how to hide any error messages when the user tabs out of the input control. Here is my code excerpts-
viewmodel-
LCAmount: ko.observable(LCAmount).extend({ insertMessages: false, required: { message: 'LC Amount is Required' } })
var saveAll = function () {
try {
var goAhead = true;
var changes = false;
SaveFlag(true);
ko.utils.arrayForEach(LoanDetails(), function (item) {
if (item.LCAmount != '')
changes = true;
if (item.errors().length > 0) {
goAhead = false;
logError("Errors on form: " + item.errors(), item, true);
}
});
if (goAhead && changes && okStoSave) {
$.prompt("Are you sure you want to save? You will not be able to change your decision after it's been saved.", {
title: "Save?",
buttons: { "Save": true, "Cancel": false },
submit: function (e, v, m, f) {
if (v) {
response = saveUpdates(LoanDetails);
});
vm.clientNumber('');
vm.clientName('');
}
}
});
}
VIEW-
<input data-bind="value: LCAmount, validationOptions: { insertMessages: false }" />