views:

41

answers:

1

Is there a way with the JQueryValidation plugin to set the input css class error. This css class is different from the label css error class.

Because if I set : errorClass: "field-validation-error"

That will apply for label and input. I would like input to have "input-validation-error" css class and label to have "field-validation-error" css class.

+3  A: 

I don't see any real reason to support different class names for the error element and the input field itself.

Just use CSS-selectors

label.field-validation-error {
  ..whatever styling...
}
input.field-validation-error {
  ..whatever styling...
}

This way both have the same css-class applied but get different styling


But if you really think you need this than you can use the highlight and unhighlight options of the validation plugin and wire them up with functions. These can then apply the wanted styles to the element and the error label. In the documentation is even a nice example of this which you should be easily able to modify to your needs

jitter
The need to support different class names for the error element and the input field come from the framework I use (Asp.Net MVC 2) that auto-generated the error class name...
Melursus
Ok then just use the second approach I described
jitter