Skip to content Skip to sidebar Skip to footer

Validate Observables Within A Collection Using Knockout Validation

I have a message field and collection of people being bound in an unordered list accompanied each with a drop down list of colors and a default selection. Validation on the message

Solution 1:

Update: With latest version of validation library you can use the live: true option to get it to listen to observableArrays

grouping: { deep:true, observable:true, live:true }

http://jsfiddle.net/fYrbt/29/

Old answer:

Sadly the group does not get reevaluated when a new item is inserted. Subscribe to the array and do it explicit.

this.items.subscribe(function() {
     this.errors = ko.validation.group(this);
     this.errors.showAllMessages();
}, this);

http://jsfiddle.net/fYrbt/

Post a Comment for "Validate Observables Within A Collection Using Knockout Validation"