[jQuery] (validate) How to have an error message per rule when using error labels
Hi,
I'm using jquery 1.3.2 and jquery.validate.js 1.5.5. I read through
the docs, and did a quick search on this list, but didn't find what I
was looking for. I want to have an error message for each rule on a
field when using error labels in the markup. As far as I know, this
can currently be done only with the "messages" option to validate().
I have something like this (hope the markup is preserved...):
<script>
$("form").validate({
errorContainer: '#errorContainer',
errorLabelContainer: '#errorContainer ul',
wrapper: 'li'
});
</script>
<form>
<label for="aField">Field with 2 rules:</label>
<input type="text" class="required digits" name="aField"
id="aField">
<input type="submit">
<div id="errorContainer">
<ul>
<li><label class="error" for="aField">A Field is required.</
label>
<li><label class="error" for="aField">A Field can contain only
digits.</label>
</ul>
</div>
</form>
Obviously, this won't work. There's no way to distinguish which error
label is for which rule. Is there a way to do this other than
specifying the messages in the JavaScript code?
Many thanks,
Bryce Lohr