diff options
author | Christopher Burger <burgerc@freeside.biz> | 2017-03-03 13:19:24 -0500 |
---|---|---|
committer | Christopher Burger <burgerc@freeside.biz> | 2017-03-03 13:19:24 -0500 |
commit | f650b4e98438c2a321ffee85bcd01d700f87b851 (patch) | |
tree | 124d1729e40ebe3879409edbb2466c795308f12f /httemplate/elements/footer.html | |
parent | 17f3758e4af48afc39bdab37b076f37a1deda3f2 (diff) |
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.
Diffstat (limited to 'httemplate/elements/footer.html')
-rw-r--r-- | httemplate/elements/footer.html | 59 |
1 files changed, 33 insertions, 26 deletions
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}; <script> - var validator = new FormValidator('<% $name %>', [ -% foreach my $field (sort keys $form) { - { - name: '<% $field %>', - rules: 'numeric' + $("form[name='<% $name %>']").validate({ + rules: { +% foreach my $field (sort keys %$validate_fields) { + '<% $field %>': { + <% $validate_fields->{$field} %> + }, +% } + }, +% if ($error_message) { + messages: { +% foreach my $field (sort keys %$error_message) { + '<% $field %>': "<% $error_message->{$field} %>", +% } }, -% } - ], - 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; - } - ); +% } + submitHandler: function(form) { + form.submit(); + } + }); </script> % } % } |