I am trying to use KnockoutValidation with conditional statements. See code below:
self.transactionType = ko.observable('Option1');
self.ConditionalField = ko.observable().extend({
required: true,
onlyIf: self.transactionType = ="Option2"
});
Unfortunately this doesn't work. I want to have ConditionalField
only required if transactionType
has value 'Option2'
.
What is the best way to use conditional validation with knockout.validation.js?