From bf951595745feebeebc8acf91a5cf846c22c6533 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 17 Feb 2017 09:37:06 -0500 Subject: [PATCH] RT# 21110 Unparsable age error. Added javascript to validate field prior to submitting the form. Also place checked prior entry in database. --- httemplate/edit/elements/edit.html | 15 +++++++++++++- httemplate/edit/process/part_event.html | 1 + httemplate/elements/footer.html | 35 +++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index a0023382e..3eb75f85f 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -240,6 +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 ' } };
{edit_topform}{$validate_field} = 'numeric'; +% } +% % my @include = % ( "/elements/$include.html", % 'field' => "$field$fieldnum", @@ -834,7 +841,11 @@ Example: : $opt{'html_foot'} %> - <% include("/elements/footer.html") %> +% my %footerdata = ( +% 'formvalidation' => $js_form_validate, +% ); + + <% include("/elements/footer.html", %footerdata) %> % } <%init> @@ -852,6 +863,8 @@ my $fields = $opt{'fields'} || [ grep { $_ ne $pkey } fields($table) ]; #my @actualfields = map { ref($_) ? $_->{'field'} : $_ } @$fields; +my $js_form_validate = {}; + my( $mode, $object); my $clone = ''; if ( $opt{'embed'} ) { diff --git a/httemplate/edit/process/part_event.html b/httemplate/edit/process/part_event.html index 4d52e7bc6..467d69ac3 100644 --- a/httemplate/edit/process/part_event.html +++ b/httemplate/edit/process/part_event.html @@ -40,6 +40,7 @@ }; } elsif ( $info->{'type'} eq 'freq' ) { $value = '0' if !length($value) and !$info->{'allow_blank'}; + $value = '0' if $value =~ /[^\d]/; $value .= $params->{$cgi_field.'_units'} if length($value); } diff --git a/httemplate/elements/footer.html b/httemplate/elements/footer.html index 32d121996..3eaa233f9 100644 --- a/httemplate/elements/footer.html +++ b/httemplate/elements/footer.html @@ -1,5 +1,40 @@ + +% if ($opt{'formvalidation'}) { +% my $form_validation = $opt{'formvalidation'}; +% foreach my $name (sort keys $form_validation) { +% my $form = $form_validation->{$name}; + +% } +% } + + +<%init> + +my(%opt) = @_; + + \ No newline at end of file -- 2.11.0