SlideShare una empresa de Scribd logo
1 de 153
Descargar para leer sin conexión
Accessibility
in pattern
libraries
Accessible form
Hints & Errors
All examples from this
presentation are available here:
http://bit.ly/hinterror
Let’s start with some basic
definitions.
What are inline error
messages?
Inline error messages are
messages that are presented in
close proximity to the relevant
form field.
They are used to inform users
that a form field has been filled
in incorrectly.
Age
Error: Must be a valid age value
These messages should inform
users of the following things:
1. That there is an error
associated with the relevant
field.
2. Information on how to
resolve the error so that the
form field can be filled in
correctly.
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.
These messages should only
appear when a user has
incorrectly filled in a form
field.
They are often dynamically
injected onto the page directly
after the user leaves that form
field.
Or, in some cases, when the
user attempts to submit the
form.
What are inline hints or
instructions?
Inline hints or instructions are
additional pieces of
information associated with
individual form fields.
Ideally, these hints should be
placed in close proximity to
the relevant form control -
either above or below.
Password
Must be at least 8 characters
These hints are designed to help
users fill in the form field
correctly.
Why “programmatically
associated” matters
In order to make inline error
messages and hints accessible,
it is important to understand
the two screen reader modes.
“Read mode” allows users to
read and navigate the page. In
this mode, users cannot enter
data into a form.
“Forms mode” allows the user
to interact with form controls
(fill in form fields etc).
In “forms mode”, keyboard
access is restricted to page
elements that can accept focus.
When screen readers are in
“forms mode”, elements that
cannot receive focus are not
announced to the user.
For example, a paragraph with
an error message after a form
control:
<label for="email">Email<label>
<input id="email" type="text">
<p>Error message</p>
This paragraph will not be
announced by screen readers
while in “forms mode”, as it is
not programmatically
associated with the form
control.
For this reason, we need to
make sure that inline error
messages and hints
programatically associated
with form controls.
Methods for inline error
messages
Here are three different
methods that could be used to
programmatically associate
error messages with their form
controls.
Method 1:

Wrapped label
Using this method, the <label>
element is wrapped around the
label content, the form control
and the inline error message.
<!-- Label wrapped around -->
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
<!-- Label content inside label -->
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
<!-- Form control inside label -->
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
<!-- Error message inside label -->
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
<!-- Matching for and id values -->
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
This method is very well
supported across all browser
and assistive technology
combinations.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS PASS
Method 2:
aria-describedby
In some cases, it is not possible
to wrap the <label> element
around the form control or
error message.
The aria-describedby attribute
can be used to explicitly
associate the error message
with the form control.
<!-- The label -->
<label for="error2">Phone number</label>
<input id="error2" type="text"

aria-describedby="d1">
<span id="d1">Error: Must be...</span>
<!-- The form control -->
<label for="error2">Phone number</label>
<input id="error2" type="text"

aria-describedby="d1">
<span id="d1">Error: Must be...</span>
<!-- The error message -->
<label for="error2">Phone number</label>
<input id="error2" type="text"

aria-describedby="d1">
<span id="d1">Error: Must be...</span>
<!-- 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>
<!-- 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>
This method is well supported
across most browser and
assistive technology
combinations.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS FAIL
Method 3:
aria-errormessage
The following technique uses
the aria-errormessage
attribute, which was
introduced as part of ARIA 1.1
in December 2017.
Using this method, the error
messages can be
programmatically associated
with the input using a matching
id and aria-errormessage
values.
<!-- The label -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
<!-- The form control -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
<!-- The error message -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
<!-- Matching for and id values -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
<!-- Matching aria-errormessage and id -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
According to the W3C
specification, authors must use
the aria-invalid attribute in
conjunction with the 

aria-errormessage attribute.
Initially, the object is in a valid
state, and the aria-invalid
attribute should be set to false.
<!-- The aria-invalid attribute set to false -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"
type="text" aria-invalid="false">
<span id="m1" aria-live="assertive"></span>
If the user enters an invalid
value, the aria-invalid
attribute must be dynamically
changed to true.
<!-- The aria-invalid true attribute -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
The specification also states
that authors can use live
regions for the error message
element - such as aria-live or
alert.
<!-- The aria-live attribute -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" aria-live="assertive">Error</span>
The error message could also be
set with role=alert.
<!-- The role=alert attribute -->
<label for="error3">Mobile number</label>
<input id="error3" aria-errormessage="m1"

type="text" aria-invalid="true">
<span id="m1" role="alert">Error</span>
Even though this method is a
WAI ARIA recommended
method, I have some concerns
with the use of assertive or
alert.
With an aria-live value of
assertive, or a role of alert
the error message should be
announced immediately.
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.
For this reason, I’d prefer to set
the aria-live value to off.
This means that assistive
technologies will be aware of
the change within that region,
but the change will not be
immediately announced to
users.
The aria-errormessage
attribute currently has no
support across any browser
and assistive technology
combinations.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
FAILFAIL FAIL FAILFAIL FAIL FAILFAIL FAIL
However, this is a W3C
recommended technique, and
could become a viable option
in the future.
Methods for inline hints
Here are three different
methods that could be used to
explicitly associate hints and
form controls.
Method 1:
Placeholder
In this example, the hint has
been provided using the
placeholder attribute.
Email
Add your email address
<!-- The label -->
<label for="hint1">Email</label>
<input id="hint1" type="text" placeholder="Add
your email address">
<!-- The form control -->
<label for="hint1">Email</label>
<input id="hint1" type="text" placeholder="Add
your email address">
<!-- Matching for and id values -->
<label for="hint1">Email</label>
<input id="hint1" type="text" placeholder="Add
your email address">
<!-- The placeholder attribute -->
<label for="hint1">Email</label>
<input id="hint1" type="text" placeholder="Add
your email address">
This method is not
recommended for the following
reasons:
1. The hint disappears as soon
as users interact with the form
control.
This is especially problematic if
there is a complex hint
message that is important for
users to be aware of as they fill
in the form field.
2. By default, the placeholder
text is displayed in a very soft
colour that fails WCAG Colour
Contrast guidelines.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS FAIL FAILPASS FAIL
Method 2:
Wrapped label
In this example, the hint has
been displayed below the form
control.
Password
Must be at least 8 characters
Like the error message example,
this method wraps the <label>
element around the label
content, the form control and
the inline hint.
<!-- The label wrapped around -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
<!-- The label content inside -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
<!-- The form control inside -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
<!-- The hint text -->
<label for="hint2">
<span>Password</span>
<input id="hint2" type="text">
<span>Must be at least 8 characters</span>
</label>
<!-- 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>
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS PASS
Method 3:
aria-describedby
Like the earlier example, the
aria-describedby can be used
to explicitly associate the error
message with the form control.
<!-- The label -->
<label for="hint3">Address</label>
<input id="hint3" type="text"

aria-describedby="d2">
<span id="d2">Use your full street address</span>
<!-- 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>
<!-- The hint -->
<label for="hint3">Address</label>
<input id="hint3" type="text"

aria-describedby="d2">
<span id="d2">Use your full street address</span>
<!-- 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>
<!-- 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>
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS FAIL
More detailed inline hints
There are times when a longer
hint message is desired.
Some authors prefer to make
this information available as a
popup tooltip.
Active customers ?
The maximum number of
active customers in a 

given month
There are two key questions
associated with popup tooltips
and form controls:
1. How do you make the popup
tooltip keyboard accessible?
2. Should this additional
information be
programmatically associated
with the form control, or
separate?
1. Popup tooltip and
keyboard access
The quickest way to make the
tooltip keyboard accessible, is to
make it visible only while in
three states: focus, hover and
active.
The tooltip can be initially
hidden off-screen.
.tooltip {
position: absolute;
top: 0;
left: -5000px;
}
Then it can be made visible

on-screen in these three
different states.
.tooltip:hover,
.tooltip:focus,
.tooltip:active {
top: -100px;
left: -10px;
}
A quick demo:
http://bit.ly/hinterror
2. Where to place the
tooltip?
Method 1: Tooltip associated
with the form control
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.
As we’ve seen before, the hint
information can be placed
inside the label, or associated
via the aria-describedby
attribute.
In this example, the tooltip
helps to explain what the term
“active customers” means.
Active customers ?
The maximum number of
active customers in a 

given month
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
Error 1 using a button:
“The label element may contain
at most one button, input,
meter, output, progress, select,
or textarea descendant.”
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.”
<!-- 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>
Method 2: Tooltip before the
form control
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>.
This reduces the amount of
information that users are
presented with for the form
control.
In this example, the tooltip
helps to explain the number.
Choose a number ?
Must be a whole number
with no factions, no
decimals and no negatives.
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- 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>
Conclusion
Make sure error messages and
hints are programmatically
associated with their form
controls.
The simplest and most stable
solution is to wrap the <label>
around the form control and
error or hint text.
If the <label> cannot wrap
around these items, the 

aria-decribedby solution is a
good alternative.
Always test any proposed
solutions with real users.
Russ Weakley
Max Design
Site: maxdesign.com.au
Twitter: twitter.com/russmaxdesign
Slideshare: slideshare.net/maxdesign
Linkedin: linkedin.com/in/russweakley

Más contenido relacionado

La actualidad más candente

5.1 css box model
5.1 css box model5.1 css box model
5.1 css box model
Bulldogs83
 

La actualidad más candente (20)

Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
Java script
Java scriptJava script
Java script
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Html basic tags
Html basic tagsHtml basic tags
Html basic tags
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Web programming
Web programmingWeb programming
Web programming
 
Html JavaScript and CSS
Html JavaScript and CSSHtml JavaScript and CSS
Html JavaScript and CSS
 
Origins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTMLOrigins and evolution of HTML and XHTML
Origins and evolution of HTML and XHTML
 
(Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS (Fast) Introduction to HTML & CSS
(Fast) Introduction to HTML & CSS
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
HTML Frameset & Inline Frame
HTML Frameset & Inline FrameHTML Frameset & Inline Frame
HTML Frameset & Inline Frame
 
5.1 css box model
5.1 css box model5.1 css box model
5.1 css box model
 
Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)Getting Started with HTML5 in Tech Com (STC 2012)
Getting Started with HTML5 in Tech Com (STC 2012)
 
Span and Div tags in HTML
Span and Div tags in HTMLSpan and Div tags in HTML
Span and Div tags in HTML
 
CSS3 Flex Layout
CSS3 Flex LayoutCSS3 Flex Layout
CSS3 Flex Layout
 
Introduction to html 5
Introduction to html 5Introduction to html 5
Introduction to html 5
 
Introduction to JavaScript Basics.
Introduction to JavaScript Basics.Introduction to JavaScript Basics.
Introduction to JavaScript Basics.
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 

Similar a Accessible Form Hints and Errors

EDD (Error Driven Development)
EDD (Error Driven Development)EDD (Error Driven Development)
EDD (Error Driven Development)
Daniel Andrews
 
Open sap ui51_week_2_unit_3_acdt_exercises
Open sap ui51_week_2_unit_3_acdt_exercisesOpen sap ui51_week_2_unit_3_acdt_exercises
Open sap ui51_week_2_unit_3_acdt_exercises
vikram sukumar
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
NALANDACSCCENTRE
 
91743410 advertisement-management-system-srs
91743410 advertisement-management-system-srs91743410 advertisement-management-system-srs
91743410 advertisement-management-system-srs
Sumit Badaya
 

Similar a Accessible Form Hints and Errors (20)

Accessible Inline errors messages
Accessible Inline errors messagesAccessible Inline errors messages
Accessible Inline errors messages
 
Building accessible web components without tears
Building accessible web components without tearsBuilding accessible web components without tears
Building accessible web components without tears
 
Accessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and gloryAccessibility in Design systems - the pain and glory
Accessibility in Design systems - the pain and glory
 
Building Accessible Web Components
Building Accessible Web ComponentsBuilding Accessible Web Components
Building Accessible Web Components
 
Access design guide for accessibility
Access design guide for accessibilityAccess design guide for accessibility
Access design guide for accessibility
 
EDD (Error Driven Development)
EDD (Error Driven Development)EDD (Error Driven Development)
EDD (Error Driven Development)
 
Open sap ui51_week_2_unit_3_acdt_exercises
Open sap ui51_week_2_unit_3_acdt_exercisesOpen sap ui51_week_2_unit_3_acdt_exercises
Open sap ui51_week_2_unit_3_acdt_exercises
 
Error Messages In Software Applications
Error Messages In Software ApplicationsError Messages In Software Applications
Error Messages In Software Applications
 
Php security
Php securityPhp security
Php security
 
Front End Frameworks - are they accessible
Front End Frameworks - are they accessibleFront End Frameworks - are they accessible
Front End Frameworks - are they accessible
 
Week2 dq2
Week2 dq2Week2 dq2
Week2 dq2
 
React Error Boundaries
React Error BoundariesReact Error Boundaries
React Error Boundaries
 
Can't Handle My Scale
Can't Handle My ScaleCan't Handle My Scale
Can't Handle My Scale
 
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdfVISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
VISUAL_BASIC_LECTURE_NOTE_A_Z_MADE_EASY.pdf
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
SOFWARE QUALITY, INTRODUCTION
SOFWARE QUALITY, INTRODUCTIONSOFWARE QUALITY, INTRODUCTION
SOFWARE QUALITY, INTRODUCTION
 
Magento 2 Layered Navigation Extension by ITORIS INC
Magento 2 Layered Navigation Extension by ITORIS INCMagento 2 Layered Navigation Extension by ITORIS INC
Magento 2 Layered Navigation Extension by ITORIS INC
 
ASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation ControlsASP.NET 05 - Exception Handling And Validation Controls
ASP.NET 05 - Exception Handling And Validation Controls
 
91743410 advertisement-management-system-srs
91743410 advertisement-management-system-srs91743410 advertisement-management-system-srs
91743410 advertisement-management-system-srs
 
UX & FinTech: 3 Ideas to Focus On
UX & FinTech: 3 Ideas to Focus OnUX & FinTech: 3 Ideas to Focus On
UX & FinTech: 3 Ideas to Focus On
 

Más de Russ Weakley

Más de Russ Weakley (20)

Accessible chat windows
Accessible chat windowsAccessible chat windows
Accessible chat windows
 
Accessible names & descriptions
Accessible names & descriptionsAccessible names & descriptions
Accessible names & descriptions
 
A deep dive into accessible names
A deep dive into accessible namesA deep dive into accessible names
A deep dive into accessible names
 
What are accessible names and why should you care?
What are accessible names and why should you care?What are accessible names and why should you care?
What are accessible names and why should you care?
 
How to build accessible UI components
How to build accessible UI componentsHow to build accessible UI components
How to build accessible UI components
 
What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?What is WCAG 2 and why should we care?
What is WCAG 2 and why should we care?
 
Accessible states in Design Systems
Accessible states in Design SystemsAccessible states in Design Systems
Accessible states in Design Systems
 
Creating accessible modals and autocompletes
Creating accessible modals and autocompletesCreating accessible modals and autocompletes
Creating accessible modals and autocompletes
 
Building an accessible progressive loader
Building an accessible progressive loaderBuilding an accessible progressive loader
Building an accessible progressive loader
 
What is accessibility?
What is accessibility?What is accessibility?
What is accessibility?
 
Accessibility in Pattern Libraries
Accessibility in Pattern LibrariesAccessibility in Pattern Libraries
Accessibility in Pattern Libraries
 
Accessibility in pattern libraries
Accessibility in pattern librariesAccessibility in pattern libraries
Accessibility in pattern libraries
 
Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24Building an accessible auto-complete - #ID24
Building an accessible auto-complete - #ID24
 
Building an accessible auto-complete
Building an accessible auto-completeBuilding an accessible auto-complete
Building an accessible auto-complete
 
Creating Acessible floating labels
Creating Acessible floating labelsCreating Acessible floating labels
Creating Acessible floating labels
 
Creating an Accessible button dropdown
Creating an Accessible button dropdownCreating an Accessible button dropdown
Creating an Accessible button dropdown
 
Creating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off SwitchCreating a Simple, Accessible On/Off Switch
Creating a Simple, Accessible On/Off Switch
 
Accessible custom radio buttons and checkboxes
Accessible custom radio buttons and checkboxesAccessible custom radio buttons and checkboxes
Accessible custom radio buttons and checkboxes
 
Deep Dive into Line-Height
Deep Dive into Line-HeightDeep Dive into Line-Height
Deep Dive into Line-Height
 
Understanding the mysteries of the CSS property value syntax
Understanding the mysteries of the CSS property value syntaxUnderstanding the mysteries of the CSS property value syntax
Understanding the mysteries of the CSS property value syntax
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Último (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 

Accessible Form Hints and Errors

  • 2. All examples from this presentation are available here: http://bit.ly/hinterror
  • 3. Let’s start with some basic definitions.
  • 4. What are inline error messages?
  • 5. Inline error messages are messages that are presented in close proximity to the relevant form field.
  • 6. They are used to inform users that a form field has been filled in incorrectly.
  • 7. Age Error: Must be a valid age value
  • 8. These messages should inform users of the following things:
  • 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.
  • 15. What are inline hints or instructions?
  • 16. Inline hints or instructions are additional pieces of information associated with individual form fields.
  • 17. Ideally, these hints should be placed in close proximity to the relevant form control - either above or below.
  • 18. Password Must be at least 8 characters
  • 19. These hints are designed to help users fill in the form field correctly.
  • 21. In order to make inline error messages and hints accessible, it is important to understand the two screen reader modes.
  • 22. “Read mode” allows users to read and navigate the page. In this mode, users cannot enter data into a form.
  • 23. “Forms mode” allows the user to interact with form controls (fill in form fields etc).
  • 24. In “forms mode”, keyboard access is restricted to page elements that can accept focus.
  • 25. When screen readers are in “forms mode”, elements that cannot receive focus are not announced to the user.
  • 26. For example, a paragraph with an error message after a form control:
  • 27. <label for="email">Email<label> <input id="email" type="text"> <p>Error message</p>
  • 28. This paragraph will not be announced by screen readers while in “forms mode”, as it is not programmatically associated with the form control.
  • 29. For this reason, we need to make sure that inline error messages and hints programatically associated with form controls.
  • 30. Methods for inline error messages
  • 31. Here are three different methods that could be used to programmatically associate error messages with their form controls.
  • 33. Using this method, the <label> element is wrapped around the label content, the form control and the inline error message.
  • 34. <!-- Label wrapped around --> <label for="error1"> <span>Age</span> <input id="error1" type="text"> <span>Error: Must be...</span> </label>
  • 35. <!-- Label content inside label --> <label for="error1"> <span>Age</span> <input id="error1" type="text"> <span>Error: Must be...</span> </label>
  • 36. <!-- Form control inside label --> <label for="error1"> <span>Age</span> <input id="error1" type="text"> <span>Error: Must be...</span> </label>
  • 37. <!-- Error message inside label --> <label for="error1"> <span>Age</span> <input id="error1" type="text"> <span>Error: Must be...</span> </label>
  • 38. <!-- Matching for and id values --> <label for="error1"> <span>Age</span> <input id="error1" type="text"> <span>Error: Must be...</span> </label>
  • 39. This method is very well supported across all browser and assistive technology combinations.
  • 40. OSX Voiceover Windows NVDA Windows JAWS SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge PASSPASS PASS PASSPASS PASS PASSPASS PASS
  • 42. In some cases, it is not possible to wrap the <label> element around the form control or error message.
  • 43. The aria-describedby attribute can be used to explicitly associate the error message with the form control.
  • 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
  • 52. The following technique uses the aria-errormessage attribute, which was introduced as part of ARIA 1.1 in December 2017.
  • 53. Using this method, the error messages can be programmatically associated with the input using a matching id and aria-errormessage values.
  • 54. <!-- The label --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 55. <!-- The form control --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 56. <!-- The error message --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 57. <!-- Matching for and id values --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 58. <!-- Matching aria-errormessage and id --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 59. According to the W3C specification, authors must use the aria-invalid attribute in conjunction with the 
 aria-errormessage attribute.
  • 60. Initially, the object is in a valid state, and the aria-invalid attribute should be set to false.
  • 61. <!-- The aria-invalid attribute set to false --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1" type="text" aria-invalid="false"> <span id="m1" aria-live="assertive"></span>
  • 62. If the user enters an invalid value, the aria-invalid attribute must be dynamically changed to true.
  • 63. <!-- The aria-invalid true attribute --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 64. The specification also states that authors can use live regions for the error message element - such as aria-live or alert.
  • 65. <!-- The aria-live attribute --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" aria-live="assertive">Error</span>
  • 66. The error message could also be set with role=alert.
  • 67. <!-- The role=alert attribute --> <label for="error3">Mobile number</label> <input id="error3" aria-errormessage="m1"
 type="text" aria-invalid="true"> <span id="m1" role="alert">Error</span>
  • 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.
  • 71. For this reason, I’d prefer to set the aria-live value to off.
  • 72. This means that assistive technologies will be aware of the change within that region, but the change will not be immediately announced to users.
  • 73. The aria-errormessage attribute currently has no support across any browser and assistive technology combinations.
  • 74. OSX Voiceover Windows NVDA Windows JAWS SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge FAILFAIL FAIL FAILFAIL FAIL FAILFAIL FAIL
  • 75. However, this is a W3C recommended technique, and could become a viable option in the future.
  • 77. Here are three different methods that could be used to explicitly associate hints and form controls.
  • 79. In this example, the hint has been provided using the placeholder attribute.
  • 81. <!-- The label --> <label for="hint1">Email</label> <input id="hint1" type="text" placeholder="Add your email address">
  • 82. <!-- The form control --> <label for="hint1">Email</label> <input id="hint1" type="text" placeholder="Add your email address">
  • 83. <!-- Matching for and id values --> <label for="hint1">Email</label> <input id="hint1" type="text" placeholder="Add your email address">
  • 84. <!-- The placeholder attribute --> <label for="hint1">Email</label> <input id="hint1" type="text" placeholder="Add your email address">
  • 85. This method is not recommended for the following reasons:
  • 86. 1. The hint disappears as soon as users interact with the form control.
  • 87. This is especially problematic if there is a complex hint message that is important for users to be aware of as they fill in the form field.
  • 88. 2. By default, the placeholder text is displayed in a very soft colour that fails WCAG Colour Contrast guidelines.
  • 89. OSX Voiceover Windows NVDA Windows JAWS SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge PASSPASS PASS PASSPASS FAIL FAILPASS FAIL
  • 91. In this example, the hint has been displayed below the form control.
  • 92. Password Must be at least 8 characters
  • 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
  • 109. There are times when a longer hint message is desired.
  • 110. Some authors prefer to make this information available as a popup tooltip.
  • 111. Active customers ? The maximum number of active customers in a given month
  • 112. There are two key questions associated with popup tooltips and form controls:
  • 113. 1. How do you make the popup tooltip keyboard accessible?
  • 114. 2. Should this additional information be programmatically associated with the form control, or separate?
  • 115. 1. Popup tooltip and keyboard access
  • 116. The quickest way to make the tooltip keyboard accessible, is to make it visible only while in three states: focus, hover and active.
  • 117. The tooltip can be initially hidden off-screen.
  • 118. .tooltip { position: absolute; top: 0; left: -5000px; }
  • 119. Then it can be made visible
 on-screen in these three different states.
  • 122. 2. Where to place the tooltip?
  • 123. Method 1: Tooltip associated with the form control
  • 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.
  • 127. Active customers ? The maximum number of active customers in a given month
  • 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>
  • 137. Method 2: Tooltip before the form control
  • 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.
  • 140. In this example, the tooltip helps to explain the number.
  • 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>
  • 149. Make sure error messages and hints are programmatically associated with their form controls.
  • 150. The simplest and most stable solution is to wrap the <label> around the form control and error or hint text.
  • 151. If the <label> cannot wrap around these items, the 
 aria-decribedby solution is a good alternative.
  • 152. Always test any proposed solutions with real users.
  • 153. Russ Weakley Max Design Site: maxdesign.com.au Twitter: twitter.com/russmaxdesign Slideshare: slideshare.net/maxdesign Linkedin: linkedin.com/in/russweakley