PDA

View Full Version : Ext.ux.MvcFormValidator - MVC 2 Client Side Model Validation with ExtJS



tdupont
3 May 2010, 11:03 AM
One of the most exciting new features in MVC 2 is "Enhanced Model Validation support across both server and client"; this new enhanced support allows for client side validation to be dynamically generated into a view from DataAnnotations attributes on models. One minor problem: Out of the box, it only uses the Microsoft AJAX libraries. Good news: We fixed that!

Ext.ux.MvcFormValidator

The MvcFormValidator is an alternative form validation context (modeled after Sys.Mvc.FormContext) that loads the generated validation configuration, and requires no changes in the MVC generated code, but uses ExtJS as it's back end. This means that the only thing you have to do is reference Ext.ux.MvcFormValidator.js, and it will enable you to use the ExtJS Core for form validation instead of having to import MicrosoftMvcValidation and the other Microsoft AJAX libraries.

Features


Requires only the ExtJS Core.
Implements all four default validators: Required, Range, StringLength, RegularExpression
Supports integration of custom validators with almost no code change.
Displays field messages as well as summary.
Extends Ext.util.Observable and uses events.
Lightweight; less than 300 lines of code.

Links


Official Blog Post (http://community.codesmithtools.com/blogs/tdupont/archive/2010/05/03/mvc-2-client-side-model-validation-with-extjs.aspx)
Ext.ux.MvcFormValidator.js (http://codesmith.googlecode.com/files/Ext.ux.MvcFormValidator.js)
Demo Solution (http://codesmith.googlecode.com/files/ExtUxMvcFormValidationDemo.zip)

techo
1 Mar 2011, 9:22 AM
This works like a charm in Fire-fox but could not see it working in IE-8.
On Submit click I get a Javascript error. Please see attached image.
Any help is appreciated?