1
votes

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

2

2 Answers

4
votes

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

0
votes

You elso can do somthing like this

$(document).ready(function () {
     ko.applyBindings(new vm(), $("#id")[0]);
     $(".validationMessage").css("color", "Red");
     vm.errors.showAllMessages(true);
});