Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery validate defaults

I'm trying to set some custom defaults for the jQuery validation plugin.

I've tried the following:

$.validate.settings.ignore = ":hidden";

and

$.validate.settings.errorPlacement = function (error, element) {
    if (element.hasClass("removedTitle"))
        error.insertAfter(element.next("img"));
    else
        error.insertAfter(element);
};

However, neither of these seem to make any difference. Is there a way to achieve this?

like image 208
ilivewithian Avatar asked Dec 21 '25 14:12

ilivewithian


1 Answers

Try:

$.validator.setDefaults({ 
    ignore: ":hidden",
    errorPlacement: function (error, element) {
        if (element.hasClass("removedTitle"))
            error.insertAfter(element.next("img"));
        else
            error.insertAfter(element);
    }
});

Further reading: http://docs.jquery.com/Plugins/Validation/Validator/setDefaults

like image 113
Rory McCrossan Avatar answered Dec 24 '25 05:12

Rory McCrossan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!