Search code examples
jqueryaddclassjquery-validation-engine

Adding a class to a form field with the jQuery Validation Engine plugin


I'm using the jQuery Validation Engine. I want the erroneous form field to be highlighted in red, as well as displaying the tooltip-error message. I think I can do this using jQuery's addClass.

My plan is to add a class 'error' to any input field that is rignt after the div.inputCreditCardformError (that is the div that holds the tooltip-error message. It appears when the field does not validate, and goes away once the field does validate.

My question is: will this added class disappear when the div.inputCreditCardformError disappears? Or will the added class stay in the page for the life of the page?


Solution

  • If you use .addClass('error'), that class will remain. You will need to place a .removeClass('error') in the code to remove the class after the field is valid. I didn't look through the code, but it should go along with the code that removes the tooltip window.