[jQuery] Re: using a different tag than label for error messages
Hi MorningZ, I just did some quick Googling on the matter, and turned up this useful link: http://www.456bereastreet.com/archive/200711/use_the_label_element_to_make_your_html_forms_accessible/ Each label element can only be associated with a single form control, while a form control may have several labels associated with it. This could be very useful for displaying hints and error messages since it would let you separate those messages in the markup for much easier positioning and styling. Unfortunately my limited screen reader testing (JAWS 8.0 and VoiceOver) of multiple labels suggests that screen readers ignore them. So it appears you are right in your semantics argument! My worry was that a single label ONLY should be used to describe the form control, such as Username, and additional labels would only serve to confuse; for example a user might think a form control had TWO names. Then again, it appears that screen readers mostly ignore additional labels. But I think I'm going to go with labels over divs for the time being. I now agree that they are the best in this situation, so thanks for spurring me to look further. Cheers, Dave
[jQuery] Re: using a different tag than label for error messages
On Jan 25, 4:24 am, Dave Stewart [EMAIL PROTECTED] wrote: Hi MorningZ, I just did some quick Googling on the matter, and turned up this useful link: http://www.456bereastreet.com/archive/200711/use_the_label_element_to... I just had to laugh at this line in that link: I always use and recommend explicit association since it feels less awkward and more exact, and has better browser compatibility (IE 6 only makes explicitly associated labels clickable the death of IE6 can't come soon enough
[jQuery] Re: using a different tag than label for error messages
CODE? And why have you posted this twice? On Jan 24, 10:00 am, Dave Stewart [EMAIL PROTECTED] wrote: Hello, I'd rather not use label tags for my error messages, as I think divs are less semantically ambiguous. Is there any way I can change the default functionality? At the moment I'm placing my own error divs manually, but I can't get them to show unless I change them to labels Help! And thanks very much. Cheers, Dave
[jQuery] Re: using a different tag than label for error messages
SORRY - the word [jQuery Validation Plugin] was supposed to appear in the title, but didn't. Hello Diego, Sorry, it's a separate question, actually. I've re-stated the first post question to clarify things, so sorry for the ambiguity. To restate the problem: Using the jQuery Validation Plugin, you can associate an element (in this case a label) with a form element in which you might display an validation error message when validating the form. The way how the plugin seems to work is to look for an associated label using the label's for attribute. I want to know if I can use any other element, such as a div, rather than a label, as I'm already using one label. (I'm going on the premise that having 2 labels would be confusing for screen readers) Thanks, Dave
[jQuery] Re: using a different tag than label for error messages
But you brought up semantics, to which the label makes way more sense in that way in this situation The error message is a label for the control (and clicking on it because of the for parameter) sets focus on said control Personally i think your premise of screen readers getting confused is not a valid one, but it's not my app :-) On Jan 24, 7:10 am, Dave Stewart [EMAIL PROTECTED] wrote: SORRY - the word [jQuery Validation Plugin] was supposed to appear in the title, but didn't. Hello Diego, Sorry, it's a separate question, actually. I've re-stated the first post question to clarify things, so sorry for the ambiguity. To restate the problem: Using the jQuery Validation Plugin, you can associate an element (in this case a label) with a form element in which you might display an validation error message when validating the form. The way how the plugin seems to work is to look for an associated label using the label's for attribute. I want to know if I can use any other element, such as a div, rather than a label, as I'm already using one label. (I'm going on the premise that having 2 labels would be confusing for screen readers) Thanks, Dave