Dan G. Switzer, II schrieb:
>
> 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.
>
> I’d 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. I’m not sure I like the name 
> “errorElement”, but you get the idea.
>
I'd have to take a look at your demo page, but it sounds like what you 
need to use is the errorPlacement option. That allows you to customize 
the placement of generated labels (instead of the default, insert after 
invalid element). Let me know if that doesn't work in your scenario.

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to