HTML::FormHandlerX::Form::JQueryValidator - Perl trait for HTML::FormHandler and JQuery Validator
0.05
use HTML::FormHandler::Moose; with HTML::FormHandlerX::Form::JQueryValidator; ... $form->to_jquery_validation_profile(); .... <input type="hidden" id="validation_json" value="[% form.as_escaped_json %]"> <script> var validationJSON = JSON.parse(decodeURIComponent($("#validation_json").val() ) ); $("#story_form").validate({ rules: validationJSON.rules, highlight: function(label) { $(label).closest('.control-group').addClass('error'); }, messages: validationJSON.messages, success: function(label) { label .text('OK!').addClass('valid') .closest('.control-group').addClass('success'); } }); }); </script>
This perl role allows you to re-use some form validation rules with the JQuery Validation plugin (http://docs.jquery.com/Plugins/Validation)
Object method, takes no arguments.
Returns as hashref holding a hash of rules and another of messages for the JQuery Validation plugin, based on the form fields of the object.
Returns the jquery validation profile as a URI escaped json string, allowing it to be stashed in a hidden form field and extracted by javascript for use with JQuery Validation plugin
Aaron Trevena, <teejay@cpan.org>
Copyright (C) 2012 by Aaron Trevena
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.
To install HTML::FormHandlerX::Form::JQueryValidator, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::FormHandlerX::Form::JQueryValidator
CPAN shell
perl -MCPAN -e shell install HTML::FormHandlerX::Form::JQueryValidator
For more information on module installation, please visit the detailed CPAN module installation guide.