From: Christopher Burger Date: Fri, 3 Mar 2017 18:19:24 +0000 (-0500) Subject: RT# 21110, Updated files to use jquery-validate jquery plugin. This allows for field... X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=968697512783294529af7353f3e87f4ecf720977;p=freeside.git 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. --- 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 64adcb975..765676777 100644 --- a/httemplate/docs/license.html +++ b/httemplate/docs/license.html @@ -138,6 +138,11 @@ 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 b056fd22d..bbc7e500b 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