Automagically add "required" class: jQuery.validate

Hi, is there a way to tell Squiz to add "required" to the class of required fields? I've spent pretty much all morning reading about this, but apologies if I've missed it!


Basically, the below addition to the "extras" field means jQuery.validate does its thing. But obviously we don't really want to have to do this every time for every form.







Thanks in advance :stuck_out_tongue:

Instead of using the jQuery Validate plugin, why not just turn on client side validation? Are there features of the jQuery plugin that the client side validation option doesn't provide?

[quote]
Instead of using the jQuery Validate plugin, why not just turn on client side validation? Are there features of the jQuery plugin that the client side validation option doesn't provide?

[/quote]



Well, because the Squiz client-side stuff is beyond horrible - it's just an alert box.



http://docs.jquery.com/Plugins/Validation#Example



That's a really simple example; I use this to add classes to both the element and the label, and of course accessible text too.

[quote]
Well, because the Squiz client-side stuff is beyond horrible - it's just an alert box.



http://docs.jquery.com/Plugins/Validation#Example



That's a really simple example; I use this to add classes to both the element and the label, and of course accessible text too.

[/quote]



Yeah, I have used jQuery Validation before, I just wanted to make sure you knew about the Matrix client side validation. Not saying it is great. :slight_smile:

[quote]
Yeah, I have used jQuery Validation before, I just wanted to make sure you knew about the Matrix client side validation. Not saying it is great. :slight_smile:

[/quote]



It's somewhat "lacking" isn't it? :slight_smile: I was thinking of trying to hack this myself so that instead of spewing out the inline Javascript alert badness, it simply spills out an array/list of required fields (and any further restrictions), which we can then feed to jQuery.validate.



Obviously this'll be done on my local copy! We host it here but Squiz look after it. Do you reckon it's likely they'd incorporate my work (assuming it's solid)?

[quote]
Obviously this'll be done on my local copy! We host it here but Squiz look after it. Do you reckon it's likely they'd incorporate my work (assuming it's solid)?

[/quote]



Sure, just submit it to the bug tracker as a feature request and there is a good chance they would add it.