Jorn,
Also, while preparing my demo I found I needed to explicitly declare in the
HTML where a validation error might appear for a given form field. I had to
actually go into the code to determine the correct way to format the <label
/> tag.
What happens if you want a static message, you do:
<label for="topic" class="error">
Please select at least two topics you'd like to receive.
</label>
If an error occurred for a field with the ID or NAME attribute of topic,
this label would be displayed.
However, if you want to define the exact placement of an error for a dynamic
message (i.e. generated from the message maps or from the rules themselves)
you have to do:
<label for="topic" class="error" generated="true"></label>
I had to dig through the code to figure out I needed to manually add the
generated attribute. Also, doing this makes the markup invalid.
Id like to see a better method of mapping individual error messages to the
correct element on the screen. Perhaps another mapping option:
$("#form").validate({
rules: {email: {required: true}},
messages: {email: "Please enter an e-mail address."},
errorElement: {email: "#errorEmail"}
});
Where the errorElement structure would allow you to define the element in
which the error gets displayed. Im not sure I like the name errorElement,
but you get the idea.
-Dan
_____
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jörn Zaefferer
Sent: Sunday, March 18, 2007 5:38 PM
To: jQuery Discussion.
Subject: [jQuery] Release: Validation plugin beta 2
The validation plugin beta 2 is out! If you are already working with it: A
update is recommended. If not, and you need client-side validation (pure or
mixed with AJAX requests), check it out:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Recent changes:
* Improved dependecy feature by adding two custom expressions:
":blank" to select elements with an empty value and ":filled" to select
elements with a value, both excluding whitespace
* Added a resetForm() method to the validator: Resets each form
element (using the form plugin, if available), removes classes on invalid
elements and hides all error messages
* Fixed docs for validator.showErrors()
* Fixed error label creation to always use html() instead of text(),
allowing arbitrary HTML passed in as messages
* Fixed error label creation to use specified error class
Have fun!
--
Jörn Zaefferer
http://bassistance.de
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/