I’ve been building out a page using ASP.NET MVC 2 using KnockoutJS, KnockoutJS Mapping plugin,, and jQuery 1.7.1. I’d like to be able to also use the KnockoutJS Validation plugin (found here). However I need to have both server and client side validation happening.
Is it possible to have my view models map to the KnockoutJS Validation plugin which uses the .extend() method?
EDIT: Example. Automatically turn this:
[Required]
public string Firstname { get; set; }
Into this:
var viewmodel = {
firstname: ko.observable().extend({ required: true });
}
In the Mvc Controls Toolkit I implemented an engine that enables the usual Mvc validation (data annotations or whatever) on knockout.js.Both client side and server side validation can be enabled. Moreover, knockout can be used with Mvc helpers, some bindings are inferred automatically, etc.