summaryrefslogtreecommitdiff
path: root/httemplate/elements/footer.html
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2017-03-03 13:19:24 -0500
committerChristopher Burger <burgerc@freeside.biz>2017-05-24 12:24:52 -0400
commit6c8a8cedc4dbfc9a9d6976718e369ed36a152670 (patch)
treeb1feb91bbd62bc0eb1c903ffc72930eaa08cb292 /httemplate/elements/footer.html
parentc67b4a1ea56e0de5787b3200055e53593275e5fa (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.html59
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>
% }
% }