Reputation: 20080
With Knockout Validation it appears that validation is performed only when a key is hit on a control which might change an observable value.
When I bind the first time, the validation is not performed (messages are not shown if the initial values are invalid). I just need to focus on one of my input controls and write a letter and unfocus it so that validation is performed.
How can I show all the messages around each control recursively just after the first binding? I tried the group
solution , but I have a nested hierarchy of validatedObservable
this produces a maxStackSize exceeded
Upvotes: 1
Views: 4817
Reputation: 928
You elso can do somthing like this
$(document).ready(function () {
ko.applyBindings(new vm(), $("#id")[0]);
$(".validationMessage").css("color", "Red");
vm.errors.showAllMessages(true);
});
Upvotes: 0
Reputation: 2491
You can configure knockout.validation to show the messages immediately.
ko.validation.init({ messagesOnModified: false });
Details about the configuration can be found at the following wiki page: https://github.com/ericmbarnard/Knockout-Validation/wiki/Configuration
Upvotes: 4