Search code examples
knockout.jsknockout-validation

How can I use Knockout.Combobox together with KnockOut Validation?


I'm trying to use Knockout.Combobox with Knockout Validation library.

https://github.com/AndersMalmgren/Knockout.Combobox

http://jsfiddle.net/Zc9Aj/

this.errors = ko.validation.group(this);
this.errors.showAllMessages();

The above doesn't work, I assume that the Validation library does not understand how to validate the Combobox binding but how do you link these two libs together?


Solution

  • Knockout Validation only supports the Value binding out of box, you can do something like this to get it to support the combobox

    http://jsfiddle.net/AWHhr/78/

    ko.bindingHandlers.comboboxValue = { 
        init: ko.bindingHandlers.validationCore.init
    };