Knockout Validation
The validation of user input is a common enough task that nearly every web application will have at least some need for. By far the most popular Knockout plugin, with 50 percent more stars on GitHub than the next Knockout related project, Knockout Validation creates several extenders and binding handlers that are designed to simplify HTML form validation.
The use of the plugin starts with extenders that apply validation logic to observables without replacing them:
var requiredValue = ko.observable().extend({ required: true }); var multipleValidationValue = ko.observable().extend({ required: true, minLength: 3, pattern: { message: 'Hey this doesnt match my pattern', params: '^[A-Z0-9].$' } });
Binding against validation-extended values is done with the normal value
binding:
<input data-bind="value: requiredValue" />
Knockout...