Check out Knockout-Validation , which carefully configures and uses what is described in the documentation by knockout . Q: Live Example 1: Forcing a Number
You can see it live in Fiddle
UPDATE : the script has been updated to use the latest versions of KO 2.0.3 and ko.validation 1.0.2 using CDN URLs for cloud computing
To install ko.validation:
ko.validation.rules.pattern.message = 'Invalid.'; ko.validation.configure({ registerExtenders: true, messagesOnModified: true, insertMessages: true, parseInputAttributes: true, messageTemplate: null });
To configure validation rules, use extensions. For example:
var viewModel = { firstName: ko.observable().extend({ minLength: 2, maxLength: 10 }), lastName: ko.observable().extend({ required: true }), emailAddress: ko.observable().extend({
Cohen Mar 05 2018-12-12T00: 00Z
source share