Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have site wide default settings for all jQuery validation uses on my site?

Tags:

People also ask

How do you check if jQuery validate is working?

The plugin adds a validationPlugin function to jQuery. fn , so simply check whether it exists or not; if (typeof jQuery. fn.

What is jQuery validation used for?

Form validation is a process of confirming the relevant information entered by the user in the input field.

What is jQuery validation plugin?

A jQuery validation plugin for Bootstrap. It's basically just a wrapper around native form validation using HTML5 attributes, but can also be used to add custom rules. It always shows error messages from the browser, automatically translated into the correct language. HTML.

How we can use jQuery validation plugins in MVC?

The jQuery validation plugin leverages a CSS selector like syntax to apply a set of validation rules. You can download the plugin (js) file from jQuery website. The password and confirm password objects are matched by the validation plugin for you and shows the message on the equalTo attribute if they don't match.


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();
  }          
});