summaryrefslogtreecommitdiff
path: root/httemplate/elements/footer.html
blob: 7f2c50ee65e8b20fdf467469b3284562cc87abd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 <%doc>

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])
    			}

   &>
 </%doc>

        </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>