Adds client-side validation to sfForms using jQuery and the jQuery Validation plugin. Rules and messages
are automatically parsed from the sfForm validation schema. Javascripts are applied with progressive enhancement using
external javascript references.

Developers

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Releases for sf 1.2

Join this plugin team

Changelog for release 1.0.0 - 24/08/2009

Added support for more validators. Fixed issue where un-named forms would not validate.
Fixed issue where single quotes in error messages caused problems. Added value replacements in error messages.
Made javascript head include urls more flexible. Fixed a number of other small bugs.

Other releases

Release 1.1.3 - 23/03/2011

Added support for sfValidatorDoctrineUnique, sfValidatorPropelUnique, embedded forms.
Fixed UTF-8 poblems. Fixed a number of other small bugs.

Release 1.1.1 - 13/06/2010

Not available

Release 1.0.0 - 24/08/2009

Added support for more validators. Fixed issue where un-named forms would not validate.
Fixed issue where single quotes in error messages caused problems. Added value replacements in error messages.
Made javascript head include urls more flexible. Fixed a number of other small bugs.

sfJqueryFormValidation plugin

The sfJqueryFormValidationPlugin is a Symfony plugin that automatically adds client-side
form validation to Symfony Forms.

The client side validation is performed using the jQuery library and the jQuery Validation plugin.

It automatically reads validation rules and messages in from the form validation schema and applies them
on the client side.

The validation is added using progressive-enhancement techniques, so no javascript code is actually
written to your HTML page.

The error messages are written to the page using the same HTML elements as the server-side validation
so you only need one set of styling rules to cover the server and client side validation messages.

Installation

Add the jQuery libary and the jQuery Validation plugin on your site in view.yml.
You can download the jQuery library from http://docs.jquery.com/Downloading_jQuery or just include
the Google-hosted version. The Validation plugin can be downloaded from http://bassistance.de/jquery-plugins/jquery-plugin-validation/

The default behavior of the plugin is to add client-side validation to all Symfony forms. If you
wish to manually select which forms get the client-side validation, you can set default:disabled, which
prevents the plugin from adding validation by default and then specify the desired forms to receive validation
in the forms: option.

The date-validation method (date) in the jQuery form validation plugin checks for US style dates, you can
optionally specify an alternate method for checking dates. In the example above, the date method is changed
to dateEN (which then needs to be defined). The example definition for dateEN is shown below.

Custom date validation method - dateEN

The jQuery form validation plugin allows you to define custom validation methods. This is a custom method
for validating dates as dd-mm-yyyy. It can be added to the same js file as the the form validation
plugin or just added somewhere in a js file that is included on pages that contain forms.