In this example the javascript rules of validation are customed via the plugin back-office.
The user must confirm his email address and the date formated field must be a date dd.mm.yyyy (example: 05.12.2000).

For the date formated field validation i used the addMethod() of the jquery validate plugin to add a regEX rule of validation.

code example:
Code added to the file « templates/custom_form.php » after the line « jQuery(function($){« 

        $.validator.addMethod(
               "regex",
                function(value, element, regexp) {
                var check = false;
                return this.optional(element) || regexp.test(value);
                },
                "Please check your input."
        );

The rules (specified via the plugin admin panel):

rules: {
  mail: {
  required: true,
  email: true
},
mail_confirm: {
  required: true,
  email: true,
  equalTo: '#mail_origin'
},
number: {
  required: true,
  regex: /^(0[1-9]|[12][0-9]|3[01])[.](0[1-9]|1[012])[.](19|20)\d\d$/
},
message: {
  required: true,
  minlength: 2
},
recipient: {
  required: true
}
}

Leave a Reply

  • (will not be published)