-
Notifications
You must be signed in to change notification settings - Fork 369
Open
Description
Hey guys! I experienced some problems when making checkboxes required (for example terms and conditions).
See here for reference: http://jsfiddle.net/v6d5y3or/
Expected behaviour: Form .isValid() should reflect the checkbox value: checkbox.true = form.true and checkbox.false = form.false
Actual behaviour: Form .isValid() is always true: checkbox.true = form.true and checkbox.false = form.true
I'm not really sure why this happens and one would think that required: true works together with the checked binding.
A temporary solution to me is to implement a custom validator to make it work as expected:
ko.observable(false).extend({
validation: [{
validator: (value, params) => Boolean(value)
}]
})