[freeside-commits] branch master updated. bf951595745feebeebc8acf91a5cf846c22c6533

Christopher Burger burgerc at 420.am
Fri Feb 17 06:39:46 PST 2017


The branch, master has been updated
       via  bf951595745feebeebc8acf91a5cf846c22c6533 (commit)
      from  c69e68e25b519c7f9d2ad47cb0ae6fc90c0f016c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit bf951595745feebeebc8acf91a5cf846c22c6533
Author: root <root at debian8-7-1>
Date:   Fri Feb 17 09:37:06 2017 -0500

    RT# 21110 Unparsable age error. Added javascript to validate field prior to submitting the form.  Also place checked prior entry in database.

diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index a002338..3eb75f85 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 ' } };
   <FORM NAME   = "edit_topform"
         METHOD = POST
         ACTION = "<% $url %>"
@@ -408,6 +409,12 @@ Example:
 %     $include_common{'layer_prefix'} = "$field$fieldnum."
 %       if $layer_prefix_on;
 %
+%     ## set conditionname field values for validation.
+%     if ($field eq 'conditionname') { 
+%       my $validate_field = $field . $fieldnum . '.after_event.run_delay';
+%       $js_form_validate->{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 4d52e7b..467d69a 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 32d1219..3eaa233 100644
--- a/httemplate/elements/footer.html
+++ b/httemplate/elements/footer.html
@@ -1,5 +1,40 @@
         </TD>
       </TR>
     </TABLE>
+
+%  if ($opt{'formvalidation'}) { 
+%    my $form_validation = $opt{'formvalidation'};
+%    foreach my $name (sort keys $form_validation) {
+%      my $form = $form_validation->{$name}; 
+    <script>
+      var validator = new FormValidator('<% $name %>', [
+%      foreach my $field (sort keys $form) {      
+        {
+          name: '<%  $field %>',
+          rules: 'numeric'
+        },
+%      }
+      ], 
+          function(errors) { 
+            if (errors.length > 0) { 
+              for (var i = 0; i<= errors.length; i++) {
+                alert ('<% $form_validation->{$name}->{errormessage} %>');
+                  //alert ('<% $form_validation->{$name}->{errormessage} %>' + errors[i].message);
+                return false;
+              }
+            }
+            return true;
+          }
+  );
+    </script>
+%    } 
+%  }
+
   </BODY>
 </HTML>
+
+<%init>
+
+my(%opt) = @_; 
+
+</%init>
\ No newline at end of file

-----------------------------------------------------------------------

Summary of changes:
 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(-)




More information about the freeside-commits mailing list