From f650b4e98438c2a321ffee85bcd01d700f87b851 Mon Sep 17 00:00:00 2001 From: Christopher Burger Date: Fri, 3 Mar 2017 13:19:24 -0500 Subject: [PATCH] RT# 21110, Updated files to use jquery-validate jquery plugin. This allows for field validation instead of just form validation. Also updated footer so it does not use experimental keys on scalar. Dereferenced hash ref prior to using keys. --- httemplate/docs/credits.html | 2 +- httemplate/docs/license.html | 5 +++ httemplate/edit/elements/edit.html | 5 ++- httemplate/elements/footer.html | 59 +++++++++++++++++------------- httemplate/elements/header-full.html | 3 +- httemplate/elements/jquery.validate.min.js | 4 ++ 6 files changed, 47 insertions(+), 31 deletions(-) create mode 100755 httemplate/elements/jquery.validate.min.js diff --git a/httemplate/docs/credits.html b/httemplate/docs/credits.html index 8bae26d9d..4daf3713c 100644 --- a/httemplate/docs/credits.html +++ b/httemplate/docs/credits.html @@ -111,7 +111,7 @@ Johan Vromans
Peter Wemm
Mark Williamson
Tim Yardley
- +Jörn Zaefferer

diff --git a/httemplate/docs/license.html b/httemplate/docs/license.html index f42c8ba84..29fa4554f 100644 --- a/httemplate/docs/license.html +++ b/httemplate/docs/license.html @@ -142,6 +142,11 @@ licensed under the terms of the MIT license. Contains js-cookie by Klaus Hartl, Fagner Brack and contributors, licensed under the terms of the MIT license. +

+Contains the form validation Jquery plugin jquery-validation + by Jörn Zaefferer, +licensed under the terms of MIT License. +

diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 3eb75f85f..377a56c79 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -240,7 +240,7 @@ Example: % my $url = $opt{'post_url'} || popurl(1)."process/$table.html"; -% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform', 'errormessage' => 'Please only numeric characters ' } }; +% $js_form_validate = { 'edit_topform' => { 'name' => 'edit_topform' } };

{edit_topform}{$validate_field} = 'numeric'; +% $js_form_validate->{edit_topform}->{validate_fields}{$validate_field} = 'digits: true'; +% $js_form_validate->{edit_topform}->{error_message}{$validate_field} = 'Please only enter numbers here.'; % } % % my @include = diff --git a/httemplate/elements/footer.html b/httemplate/elements/footer.html index 7f2c50ee6..f178b57c8 100644 --- a/httemplate/elements/footer.html +++ b/httemplate/elements/footer.html @@ -4,12 +4,18 @@ Example: <& /elements/footer.html, 'formname' => { #actual name of the form you want validated - 'name' => # name of the form - 'errormessage' => # js error message to display - 'fieldname' => # fieldname is actual name of field to be validated and value is type of validation - # validation types are required, valid_email, min_length(min_length[5]), max_length(max_length[7]), - # exact_length(exact_length[6]), greater_than(greater_than[4]), less_than(less_than[6]), - # alpha, alpha_numeric, numeric, valid_ip, is_file_type(is_file_type[gif,png,jpg]) + 'name' => # name of the form + 'validate_fields' => # list of key/value pairs with key being name of field to be validated and value is type + # of validation + # validation types are + # required: true, email: true, url: true, number: true, digits: true + # validation size types are + # minlength: n, maxlength: n, rangelength: [n, n] + # validation value types are + # min: n, max: n, range: [n, n], + 'error_message' => # list of key/value pairs with key being name of field to be validated and value is error + # message to display + } &> @@ -21,28 +27,29 @@ Example: % if ($opt{'formvalidation'}) { % my $form_validation = $opt{'formvalidation'}; -% foreach my $name (sort keys $form_validation) { -% my $form = $form_validation->{$name}; +% foreach my $name (sort keys %$form_validation) { +% my $validate_fields = $form_validation->{$name}->{validate_fields}; +% my $error_message = $form_validation->{$name}->{error_message}; % } % } diff --git a/httemplate/elements/header-full.html b/httemplate/elements/header-full.html index e5b363862..e6130b2b1 100644 --- a/httemplate/elements/header-full.html +++ b/httemplate/elements/header-full.html @@ -47,6 +47,7 @@ Example: + % if ( $FS::CurrentUser::CurrentUser->option('printtofit') ) { % } @@ -56,8 +57,6 @@ Example: <% $head |n %> - - %# announce our base path, and the Mason comp path of this page