The document discusses several methods for programmatically associating inline error messages and hints with form fields to ensure they are accessible to screen reader users. It describes wrapping form fields and messages in <label> tags, using aria-describedby to link them, and aria-errormessage as recommended by WAI-ARIA. For longer hints, it suggests using pop-up tooltips but ensuring they are accessible via keyboard by only showing on focus, hover or active states. The tooltip content should be directly associated with the relevant form field for maximum accessibility.
9. 1. That there is an error
associated with the relevant
field.
10. 2. Information on how to
resolve the error so that the
form field can be filled in
correctly.
11. 3. Ideally, the error message
should be relevant and
contextual rather than being
too generic.
Some of the examples in my slides are very generic
due to space restrictions.
12. These messages should only
appear when a user has
incorrectly filled in a form
field.
13. They are often dynamically
injected onto the page directly
after the user leaves that form
field.
14. Or, in some cases, when the
user attempts to submit the
form.
44. <!-- The label -->
<label for="error2">Phone number</label>
<input id="error2" type="text"
aria-describedby="d1">
<span id="d1">Error: Must be...</span>
45. <!-- The form control -->
<label for="error2">Phone number</label>
<input id="error2" type="text"
aria-describedby="d1">
<span id="d1">Error: Must be...</span>
46. <!-- The error message -->
<label for="error2">Phone number</label>
<input id="error2" type="text"
aria-describedby="d1">
<span id="d1">Error: Must be...</span>
47. <!-- Matching for and id values -->
<label for="error2">Phone number</label>
<input id="error2" type="text"
aria-describedby="d1">
<span id="d1">Error: Must be...</span>
48. <!-- Matching aria-describedby and id -->
<label for="error2">Phone number</label>
<input id="error2" type="text"
aria-describedby="d1">
<span id="d1">Error: Must be...</span>
49. This method is well supported
across most browser and
assistive technology
combinations.
50. OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS FAIL
68. Even though this method is a
WAI ARIA recommended
method, I have some concerns
with the use of assertive or
alert.
69. With an aria-live value of
assertive, or a role of alert
the error message should be
announced immediately.
70. If the error message is is
dynamically inserted as the
user leaves a form control, the
error message could be
announced over the top of the
next form control label.
93. Like the error message example,
this method wraps the <label>
element around the label
content, the form control and
the inline hint.
94. <!-- The label wrapped around -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
95. <!-- The label content inside -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
96. <!-- The form control inside -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
97. <!-- The hint text -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
98. <!-- Matching for and id values -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
99. OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS PASS
101. Like the earlier example, the
aria-describedby can be used
to explicitly associate the error
message with the form control.
102. <!-- The label -->
<label for="hint3">Address</label>
<input id="hint3" type="text"
aria-describedby="d2">
<span id="d2">Use your full street address</span>
103. <!-- The form control -->
<label for="hint3">Address</label>
<input id="hint3" type="text"
aria-describedby="d2">
<span id="d2">Use your full street address</span>
104. <!-- The hint -->
<label for="hint3">Address</label>
<input id="hint3" type="text"
aria-describedby="d2">
<span id="d2">Use your full street address</span>
105. <!-- Matching for and id values -->
<label for="hint3">Address</label>
<input id="hint3" type="text"
aria-describedby="d2">
<span id="d2">Use your full street address</span>
106. <!-- Matching aria-describedby and id values -->
<label for="hint3">Address</label>
<input id="hint3" type="text"
aria-describedby="d2">
<span id="d2">Use your full street address</span>
107. OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS FAIL
124. If the hint information is
critical for users to
understand when filling in the
form field, then it needs to be
programmatically associated
with the form control.
125. As we’ve seen before, the hint
information can be placed
inside the label, or associated
via the aria-describedby
attribute.
126. In this example, the tooltip
helps to explain what the term
“active customers” means.
128. <!-- The label wrapped around -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
129. <!-- The label content inside -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
130. <!-- The form control -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
131. <!-- Matching for and id attributes -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
132. <!-- The tooltip -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
133. <!-- A role of button -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
134. Error 1 using a button:
“The label element may contain
at most one button, input,
meter, output, progress, select,
or textarea descendant.”
135. Error 2 using a button:
“Any button descendant of a
label element with a for
attribute must have an ID
value that matches that for
attribute.”
136. <!-- Hidden content -->
<label for="hint4">
Active customers
<a href="#" role="button">
<span class="tooltip">
<span class="hidden">is defined as</span>
The maximum number...
</span>
</a>
<input id="hint4" type="text">
</label>
138. If the hint information is
informative, but not critical, it
could be presented to users as a
separate element, before the
relevant form control and
<label>.
139. This reduces the amount of
information that users are
presented with for the form
control.
141. Choose a number ?
Must be a whole number
with no factions, no
decimals and no negatives.
142. <!-- The button before the form control -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>
143. <!-- Hidden content in the button -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>
144. <!-- The label wrapped around -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>
145. <!-- The label content -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>
146. <!-- The form control -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>
147. <!-- Matching for and id values -->
<button>
<span class="hidden">For the following</span>
<span class="tooltip">Must be...</span>
</button>
<label for="hint6">
<span>Choose a number</span>
<input id="hint6" type="text">
</label>