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.
views:
24answers:
2
A:
I would suggest to simply add a class for your green-state only if the field has a validation-failed-class already.
elusive
2010-09-15 18:06:22
+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
2010-09-15 18:17:01
Thanks, its working.
vaibhav
2010-09-15 18:27:22
@vaibhav - Glad I could help. If you don't mind, could you accept the answer as well? Would be much appreciated.
JasCav
2010-09-15 18:29:30