You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm brand new to KO and KO validation and I was wondering if anyone could help point me in the right direction?
I've created a form running as a SPA but I need validation on text areas to activate depending on the previous's select element's value (which is bound to a knockout value).
For example,
self.standardConstruction = ko.observable().extend({ required: true });
self.constructionType = ko.observable().extend({ required: {onlyIf: standardConstruction() === 'Yes'} });
However, I've found the onlyIf statement doesn't allow for anonymous functions and I can't set the array that populates my "[blank] ,'Yes', 'No'" fields to actually equate to true/false in the code behind.
I'm hoping there's a way of writing a custom validation rule that allows me to pass a value, an expected value and then activate the required: true flag based off that!
Hi there,
I'm brand new to KO and KO validation and I was wondering if anyone could help point me in the right direction?
I've created a form running as a SPA but I need validation on text areas to activate depending on the previous's select element's value (which is bound to a knockout value).
For example,
self.standardConstruction = ko.observable().extend({ required: true });
self.constructionType = ko.observable().extend({ required: {onlyIf: standardConstruction() === 'Yes'} });
However, I've found the onlyIf statement doesn't allow for anonymous functions and I can't set the array that populates my "[blank] ,'Yes', 'No'" fields to actually equate to true/false in the code behind.
I'm hoping there's a way of writing a custom validation rule that allows me to pass a value, an expected value and then activate the required: true flag based off that!
////Knockout validation rules
//ko.validation.rules['isReqYes'] = {
// validator: function( param, expected) {
// if(param === expected)
// {
// required: true
// }
// },
//
// message: 'This field is required.',
//};
Unfortunately I can't find much documentation and my experience is lacking so I'm making no headway! Any and all help is appreciated :D
Also, thanks for the library, it's been a great help with my project so far!
Regards,
Antony
The text was updated successfully, but these errors were encountered: