For those of us using jQuery there was nothing, so we decided to write our own small helper that integrates this jQuery validator with the new forms. It’s nothing fancy, but it does the trick for now, and we may expand it into a full-fledged plugin that does all sorts of crazy things.
Using the helper:
- Download and install the jQuery validation plugin.
- Download the helper and put it in
- Include the jQueryVal helper.
- To enable the helper for a specific form:
<?php echo jquery_val_form_tag($form, array(‘action’ => url_for(“@register“) ))?>
The validator currently supports email, min and max length validation. The only required option is action, the other options you can pass it are:
error_placement: Change where the errors are rendered, for example:
'error_placement' => 'error.prependTo(element.parent().next())'
error_element: Change the element used to render the errors, default is label.
All other options you pass are added to the form as attributes.