views:

24

answers:

2

I am using JS fiddle for trying my hands on jquery validation. You can access the code at http://jsfiddle.net/8MmCS/3/
I am changing the background color of a control to 'red' if its validation fails. And if the data entered is validated, then the control border is changed to green.
But I need to change the border color to green , only if validation had failed previously.

A: 

I would suggest to simply add a class for your green-state only if the field has a validation-failed-class already.

elusive
+2  A: 

You want to change your unhighlight parameter to this:

unhighlight: function(element, errorClass, validClass) {
        if($(element).hasClass('mandatory')) {
            $(element).removeClass('mandatory').addClass('success');
        }
    }

I updated your example here: http://jsfiddle.net/8MmCS/5/

JasCav
Thanks, its working.
vaibhav
@vaibhav - Glad I could help. If you don't mind, could you accept the answer as well? Would be much appreciated.
JasCav