Diogo Cardoso
Diogo Cardoso

Reputation: 22257

jQuery Validation add valid class to another element

Is there any equivalent of the errorPlacement for the validPlacement in jQueryValidation?

My goal is to add the valid class to another element.

Thanks.

Upvotes: 3

Views: 2037

Answers (2)

Diogo Cardoso
Diogo Cardoso

Reputation: 22257

I solved the problem using success option.

var validatorOptions = {    
    success: function(label) {
        var element = '#' + label.attr('for');
        $(element).addClass('myClass');
    }
};

Upvotes: 2

Teddy
Teddy

Reputation: 18572

You can write a custom validation function. A custom validation function takes 2 arguments: value and element

That gives you access to the element parameter.

Upvotes: 0

Related Questions