knockout-validation plugin, get isValid from specific property
Asked Answered
A

1

8

Is is possible to see if just one property is valid in the knockout-validation plugin?

I could not see any reference to it in the documentation, only the ability to see if the whole model is valid.

For example I wish a computed observable to have a different value depending upon if another observable is valid.

Ahouh answered 8/2, 2013 at 16:23 Comment(0)
A
14

I was being led down the wrong direction, as I was using async validators and over complicated my problem, I think it is as simple as:

propertyName.isValid();

e.g.

self.email.isValid();

Ahouh answered 8/2, 2013 at 16:32 Comment(3)
Hello, @AlexKey. Sorry about this "bump", but I would to know why I am receiving this message from console: Uncaught TypeError: Cannot call method 'isValid' of undefined . Actually, I know why, but I do not know how to resolve. By chance, it happened to you?Filippo
Hi @chiefGui pop your comment into a question (so the information doesn't get lost in comments) and pop a link to it here and I'll take a look for you.Ahouh
@GuilhermeOderdenge FYI, this maybe because you're evaluating the value of the observable and not the observable itself, for example you might be doing myObservable().isValid() instead of myObservable.isValid(). Just figured that out myself and wanted to share.Mina

© 2022 - 2024 — McMap. All rights reserved.