Mika Tuupola wrote:

http://bassistance.de/jquery-plugins/jquery-plugin-validation/

Lets assume I have following HTML

<tr>
  <td class="label">
    <label for="date" class="required">Some date:</label>
  </td>
  <td>
<input type="text" class="text {required:true}" name="date" id="date" />
   </td>
</tr>

Now what I want to happen is that when form fails validation (date is empty), label for date gets class "error" added.

In my case I do not want customized error messages. Just change class of the label of the input.

There must be a simple way to do it. I just cant seem to find it...
RC1 adds the error class to the input's parent element. Unfortuanetely that doesn't help in your layout. I guess I need to implement a way to customize that error-class-adding.

Until then you have two options: errorPlacement and showErrors. Implement one or the other to add the necessary classes. Some stubs to get you started, let me know if anything works for you:

showErrors: function(errors) {
 jQuery.each(errors, function(i, n) {
   jQuery("[EMAIL PROTECTED]" + i + "]").addClass("error");
 }
}
errorPlacement: function(label, element) {
 label.insertAfter(element);
 element.parent().prev().find("label").addClass("error");
}

--
Jörn Zaefferer

http://bassistance.de

Reply via email to