1

I have an element with a css class ".validate_txt_sContactPhone" and after this validation, would like to apply new css class to the element.

$(".validate_txt_sContactPhone").rules("add", {
          required: true,
          minlength: 2,
          messages: {
              required: "",
              minlength: jQuery.format("2*")
          }

      })
4
  • 1
    Do you want it to require a certain CSS class? Not sure what you mean. Commented Dec 22, 2011 at 17:50
  • 1
    If you are using the jQuery Validation Plugin then what you are looking for is the validClass/errorClass options to the .validate() function. Commented Dec 22, 2011 at 17:53
  • Is this to be taken as "How do I, when invalid, have jQuery validator add a custom CSS class to the element?" Commented Dec 22, 2011 at 17:53
  • Im sorry for not being clear. I have updated my post. Commented Dec 22, 2011 at 17:58

1 Answer 1

1

If you are using the jQuery Validation Plugin then what you are looking for is the validClass/errorClass options to the .validate() function.

I would recommend reading through all the options on that page, some that may be useful to you:

invalidHandler
success
errorClass
validClass
Sign up to request clarification or add additional context in comments.

2 Comments

thanks for your reply, but I am not supposed that logic, company policy :) can you tell me remove next div element to this ".validate_txt_sContactPhone" in the above validation logic.
I have no idea what you are asking for at all. CSS classes (and callbacks) are registered through the validate function, not the rules interface because its not a rule.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.