+ <%doc>
+
+Example:
+
+ <& /elements/footer.html,
+ 'formname' => { #actual name of the form you want validated
+ '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
+
+ }
+
+ &>
+ </%doc>
+
</TD>
</TR>
</TABLE>
+
+% if ($opt{'formvalidation'}) {
+% my $form_validation = $opt{'formvalidation'};
+% foreach my $name (sort keys %$form_validation) {
+% my $validate_fields = $form_validation->{$name}->{validate_fields};
+% my $error_message = $form_validation->{$name}->{error_message};
+ <script>
+ $("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} %>",
+% }
+ },
+% }
+ submitHandler: function(form) {
+ form.submit();
+ }
+ });
+ </script>
+% }
+% }
+
</BODY>
</HTML>
+
+<%init>
+
+my(%opt) = @_;
+
+</%init>
\ No newline at end of file