Abhimanyu
Abhimanyu

Reputation: 589

jquery validation handling error css

script.js

$('#registerform').validate({
            errorElement: "div",
                    wrapper: "div",  // a wrapper around the error message
                    errorPlacement: function(error, element){
                    error.appendTo( element.parent().next() );
                    error.css('padding-left','30');
                    element.addClass('error-field');
            },
                    debug:true

        });

doubt

how am i suppose to remove the class error-field if the field is valid?

Upvotes: 0

Views: 205

Answers (1)

Nick Rameau
Nick Rameau

Reputation: 1318

I don't use that plugin that much, but according to the doc, you simply add a success parameter:

$('#registerform').validate({
        errorElement: "div",
                wrapper: "div",  // a wrapper around the error message
                errorPlacement: function(error, element){
                error.appendTo( element.parent().next() );
                error.css('padding-left','30');
                element.addClass('error-field');
        },
                debug:true,
                success: function() {
                    element.removeClass('error-field');
                })

    });

Upvotes: 1

Related Questions