JQuery Validate Plugin Itegration - Update

Topics: Developer Forum
May 14, 2008 at 6:21 PM
I've been in touch with the author of the JQuery Validation plugin. He's willing to let me contribute an update that will support custom error messages in metadata. The suggested implementation involves specifying the rules/messages in the class attribute of the element to validate. So a input element would look something like this:

<input id="cemail" name="email" class="{ rules: { required:true, email:true },  messages { required:"Custom req msg", email:"Custom email msg" } " />

A developer could then manually call the "validate" method specifying any additional options or overriding the ones provided in the metadata.

Personally I'm not a fan of using the class attribute to save these rules as I feel like it artificially creates some collision problems when we want to simple style the element. But this may be unwarranted and changing the way his framework does things might not be something he's interested in.

In any event I figured I'd keep everyone posted incase there is any feedback/suggestions.
May 14, 2008 at 6:29 PM
Upon further reflection using the class attribute allows the html to remain standards compliant. So maybe its not that bad.
May 14, 2008 at 9:11 PM
Edited May 14, 2008 at 9:12 PM
[edit] Double post ... 3 hrs later?
May 15, 2008 at 6:17 PM
I've finished and tested the jquery validate plugin modifications. If the changes are accepted the plugin will support custom error messages in metadata as described above.

I'll wait to see if the changes are accepted before I start adding the "advanced" client-side error display functionality to the framework's web project.
May 17, 2008 at 10:25 PM
OK. I've gotten some good feedback. The plugin modification syntax is going to change to:

<input class="{ required:true, email:true,  messages: { required:'Custom req msg', email:'Custom email msg' } } " />

This keeps the jQuery plugin's current API fully intact. Pretty confident this is will stand so i'll start to add integrate the changes later this weekend.
May 18, 2008 at 12:54 AM
Great news dane.
I too much prefer the syntax of placing messages inside the html element.

Sep 5, 2008 at 8:36 PM
Has there been any progress on integrating ValidationFramework with jQuery's Validate plugin?
Sep 5, 2008 at 9:21 PM
Yes. As of beta release 2.0 (i think it was that release) we had JQuery integrated. MVC Preview 5 (released last fri) enhanced .net's native support for validation. The direction the team MVC took its validation support diverged a bit from where we'd taken it. Over the past week I've stripped out our previous support and am working twards integrating the new mvc preview 5 conepts. The default client-side generator will be using JQuery validate plugin.

I've checked in a 'frist pass', but I'm still activley developing it. I'm expecting to have a initial integration with preview 5 done by the end of the weekend. You can take a look at the current source if you want. Any input would be greatly appreciated.