jQuery validatoin plugin - site wide settings

Posted by Daveo on Stack Overflow See other posts from Stack Overflow or by Daveo
Published on 2010-04-07T04:40:08Z Indexed on 2010/04/07 4:43 UTC
Read the original article Hit count: 323

I want to have site wide default settings for all jQuery validation uses on my site, I want every form to use the below settings, but then on a per form basis change the rules and messages. Is this possible?

 $('#myForm').validate({

  errorClass: 'field-validation-error',
  errorElement: 'span',
  errorPlacement: function(error, element) {
        element.next('span').remove();
        error.insertAfter( element )
         .removeClass('field-validation-error')
         .addClass('ui-state-error');

    },
    success: function(label) {
            label.remove();
  }          
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery