Search code examples
validationknockout.jsknockout-validation

How to explicitly validate a knockoutJs observable


I'm using KnoockoutJS and the validation plugin from here, https://github.com/ericmbarnard/Knockout-Validation.

By default, validation messages only appear after a field has been modified. The problem is that when the user clicks "Save", I need to validate the bound observable regardless of whether the user has modified the field or not.

I can't seem to find a .Validate()on an obervable...


Solution

  • Looks like ko.validation.validateObservable might be what you're looking for... I didn't test it, but that looks like it.