SlideShare a Scribd company logo
Accessibility
in pattern
libraries
Accessible
Inline Error
Messages
Examples from this
presentation:
http://bit.ly/hinterror
What are inline
error messages?
Let’s look at a simple example:
Age
Error: Must be a valid age value!
Label
Age
Error: Must be a valid age value!
Form control
Age
Error: Must be a valid age value!
Error message
Purpose of error
messages?
They should inform users that
there has been an error.
They should provide users
with help to fill in the field.
Help should be contextual.
When should error
messages appear?
They should only appear after
users fill in field incorrectly.
They should be either
dynamically injected directly
after focus leaves the field or
on form submit.
Appearance
They should be placed in close
proximity to the form field.
They should not use colour
alone to indicate the state.
They should include some
visual indicator, so they work
without the need for colour.
Age
Error: Must be a valid age value!
Visual indicator
Why
“programmatically
associated”?
Screen readers have two
different modes.
These are “read mode” and
“forms mode”.
“Read mode” allows users to
read and navigate the page.
In this mode, users can’t enter
data into a form.
“Forms mode” allows the user
to interact with form
controls.
Keyboard access is restricted
to elements that accept focus.
Elements that can’t receive
focus will not be announced
to ATs.
Let’s look at a simple example:
<label for="email">Email<label>
<input id="email" type="text">
<p>Error message</p> Label
<label for="email">Email<label>
<input id="email" type="text">
<p>Error message</p>
Form control
<label for="email">Email<label>
<input id="email" type="text">
<p>Error message</p>
Error message
This error message will not be
announced by screen readers
while in “forms mode”.
Why?
Because the <p> is not an
element that receives focus.
And, because the element is
not programmatically
associated with the form
control.
Our aims is to make all inline
error messages
programatically associated
with their form controls.
Four methods
Method 1:

Wrapped label
Using this method, the
<label> is wrapped around
everything else.
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
Wrapped label
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
Label content
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label> Form control
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
Error message
<label for="error1">
<span>Age</span>
<input id="error1" type="text">
<span>Error: Must be...</span>
</label>
Matching for and id
This method is very well
supported.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS PASS
Method 2:
aria-describedby
Sometimes, it’s not possible to
wrap the <label> around
everything else.
aria-describedby can be used
to programmatically
associate the error message
with the form control.
<label for="error2">Phone number</label>
<input id="error2" type="text"

aria-describedby="description1">
<span id="description1">Error: Must be...</span>
Label
<label for="error2">Phone number</label>
<input id="error2" type="text"

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

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

aria-describedby="description1">
<span id="description1">Error: Must be...</span>
Matching for and id
<label for="error2">Phone number</label>
<input id="error2" type="text"

aria-describedby="description1">
<span id="description1">Error: Must be...</span>
Matching aria-describedby and id
This method is well
supported.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS FAIL
Method 3:
aria-labelledby
aria-labelledby can be used
to programmatically
associate the error message
with the form control.
Warning: 

Using this method, the aria-
labelledby content will be
announced to ATs but the label
content will not.
This can be resolved by giving
the label an id and adding this
value to the aria-labelledby
attribute.
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Label
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Form control
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Error message
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Matching for and id
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Matching aria-describedby and id
<label for="error3" id="label1">Address</label>
<input id="error3" type="text"
aria-labelledby="label1 label2">
<span id="label2" role="tooltip">Error:</span>
Matching aria-describedby and id
This method is well
supported.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
PASSPASS PASS PASSPASS PASS PASSPASS PASS
However, I prefer to use aria-
describedby instead of aria-
labelledby.
These error messages are
additional descriptions to the
form control and its label,
rather than being labels
themselves.
Method 4:
aria-errormessage
aria-errormessage was
introduced with ARIA 1.1 in
December 2017.
aria-errormessage can be
used to programmatically
associate the error message
with the form control.
<label for="error4">Mobile number</label>
<input id="error4" type="text"

aria-errormessage="errormessage1">
<span id="errormessage1">Error: Must be...</span>
Label
<label for="error4">Mobile number</label>
<input id="error4" type="text"

aria-errormessage="errormessage1">
<span id="errormessage1">Error: Must be...</span>
Form control
<label for="error4">Mobile number</label>
<input id="error4" type="text"

aria-errormessage="errormessage1">
<span id="errormessage1">Error: Must be...</span>
Error message
<label for="error4">Mobile number</label>
<input id="error4" type="text"

aria-errormessage="errormessage1">
<span id="errormessage1">Error: Must be...</span>
Matching for and id
<label for="error4">Mobile number</label>
<input id="error4" type="text"

aria-errormessage="errormessage1">
<span id="errormessage1">Error: Must be...</span>
Matching aria-errormessage and id
This method currently has no
support.
OSX Voiceover Windows NVDA Windows JAWS
SafariChrome Opera FirefoxChrome Edge FirefoxChrome Edge
FAILFAIL FAIL FAILFAIL FAIL FAILFAIL FAIL
However, it could become a
viable option in the future.
Using aria-invalid
Regardless of the method, the
aria-invalid attribute should
also be used with form
controls.
This attribute helps inform
assistive technologies about
the state of form control.
The value should initially be
set to false when the form
field has no invalid data.
<label for="error3">Mobile number</label>
<input id="error3" type="text"

aria-errormessage="m1" aria-invalid="false">
<span id="m1"></span>
False value
The value can then be
dynamically switched to true
when the form field has
invalid data.
<label for="error3">Mobile number</label>
<input id="error3" type="text"

aria-errormessage="m1" aria-invalid="true">
<span id="m1">Error: Must be...</span>
True value
Using aria-live
The aria-live attribute
informs ATs that dynamic
changes may occur within a
page region.
This can help when injecting
error messages into a page
region.
<span id="m1" aria-live="off"></span>
No error message
<span id="m1" aria-live="off">Error...</span>
Error message
The three possible values are
off, polite and assertive.
aria-live="off"
AT should not announce
updates unless focused on
that region.
aria-live="polite"
AT should announce updates
at the next graceful
opportunity.
aria-live="assertive"
AT should announce updates
immediately.
The assertive value should be
avoided for inline error
messages.
The error message could be
announced over the top of the
next form control label.
The role=alert should also be
avoided.
The role=alert has an
intrinsic aria-live value of
assertive.
The off value is preferred as it
lets users continue with the
form process without
interruptions.
Conclusion
Make sure error messages are
programmatically associated
with their form controls.
And always test any proposed
solutions - with different
assistive technologies and
with real users!
Russ Weakley
Max Design
Site: maxdesign.com.au
Twitter: twitter.com/russmaxdesign
Slideshare: slideshare.net/maxdesign
Linkedin: linkedin.com/in/russweakley

More Related Content

What's hot (20)

PPTX
Oracle Fusion Architecture
Vinay Kumar
 
PDF
Sql tutorial
Fidelis Nwachukwu
 
PDF
SAP Business One Integration Problems and Solutions - DI server DI API B1WS
APPSeCONNECT
 
PDF
Autodesk company presentation
John Murphy
 
PDF
Creating an Accessible button dropdown
Russ Weakley
 
PDF
Advanced Schema Design Patterns
MongoDB
 
PDF
Fusion absence management explained with examples
mshabrawi
 
PPTX
Oracle Fusion Financial Report Centre Reporting Beginner course
Khalil Rehman NLP (MPrac) MCIPS, PMP,OCP
 
PDF
Basic JavaScript Tutorial
DHTMLExtreme
 
DOCX
How to debug a fast formula
Feras Ahmad
 
PDF
Configuring Parallel Approvers Notification
Feras Ahmad
 
PPT
Oracle Assets
Mohamed159686
 
DOC
Recruitment process through core hr
Feras Ahmad
 
PPT
Introduction to Oracle ERP
Balaji Parsewar
 
PPT
WordPress Installation Tutorial - How to Install WordPress manually
Balaji kaliamoorthy
 
PPTX
HTML Introduction
Hameda Hurmat
 
PPT
Oracle Forms: Master Detail form
Sekhar Byna
 
PDF
23 workflow approvals
mohamed refaei
 
PDF
Salesforce cti integration case study
Cloud Analogy
 
Oracle Fusion Architecture
Vinay Kumar
 
Sql tutorial
Fidelis Nwachukwu
 
SAP Business One Integration Problems and Solutions - DI server DI API B1WS
APPSeCONNECT
 
Autodesk company presentation
John Murphy
 
Creating an Accessible button dropdown
Russ Weakley
 
Advanced Schema Design Patterns
MongoDB
 
Fusion absence management explained with examples
mshabrawi
 
Oracle Fusion Financial Report Centre Reporting Beginner course
Khalil Rehman NLP (MPrac) MCIPS, PMP,OCP
 
Basic JavaScript Tutorial
DHTMLExtreme
 
How to debug a fast formula
Feras Ahmad
 
Configuring Parallel Approvers Notification
Feras Ahmad
 
Oracle Assets
Mohamed159686
 
Recruitment process through core hr
Feras Ahmad
 
Introduction to Oracle ERP
Balaji Parsewar
 
WordPress Installation Tutorial - How to Install WordPress manually
Balaji kaliamoorthy
 
HTML Introduction
Hameda Hurmat
 
Oracle Forms: Master Detail form
Sekhar Byna
 
23 workflow approvals
mohamed refaei
 
Salesforce cti integration case study
Cloud Analogy
 

Similar to Accessible Inline errors messages (20)

PPTX
Accessible dynamic forms
Dylan Barrell
 
PDF
Web Forms People Don't Hate
cliener
 
PDF
Building accessible web components without tears
Russ Weakley
 
PPTX
Making FAIL More Fun
Dawa Riley
 
PPTX
Errors and error rates: workshop for X-Gov content clubpptx
Caroline Jarrett
 
PPT
Accessible forms
BarrierBreak
 
PDF
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
DOCX
Graded document project2
NagellaRanjithKumar
 
PDF
Forms
Aaron Maturen
 
KEY
Building & Breaking Web Forms with Quaid-JS
cliener
 
PPTX
Web topic 22 validation on web forms
CK Yang
 
PDF
Why Nobody Fills Out My Forms
All Things Open
 
PDF
Why Nobody Fills Out My Forms
Andrew Malek
 
PPTX
PHP Form Validation Technique
Morshedul Arefin
 
PDF
Why Nobody Fills Out My Forms (Updated)
Andrew Malek
 
PDF
YUI + Accessibility: Welcome the whole world
Ted Drake
 
PDF
We can do better than "unknown error"
cphcharli
 
PDF
Tips for-coding-and-designing-usabl
Daniel Downs
 
PDF
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
PPTX
Form using html and java script validation
Maitree Patel
 
Accessible dynamic forms
Dylan Barrell
 
Web Forms People Don't Hate
cliener
 
Building accessible web components without tears
Russ Weakley
 
Making FAIL More Fun
Dawa Riley
 
Errors and error rates: workshop for X-Gov content clubpptx
Caroline Jarrett
 
Accessible forms
BarrierBreak
 
HTML5 Forms - KISS time - Fronteers
Robert Nyman
 
Graded document project2
NagellaRanjithKumar
 
Building & Breaking Web Forms with Quaid-JS
cliener
 
Web topic 22 validation on web forms
CK Yang
 
Why Nobody Fills Out My Forms
All Things Open
 
Why Nobody Fills Out My Forms
Andrew Malek
 
PHP Form Validation Technique
Morshedul Arefin
 
Why Nobody Fills Out My Forms (Updated)
Andrew Malek
 
YUI + Accessibility: Welcome the whole world
Ted Drake
 
We can do better than "unknown error"
cphcharli
 
Tips for-coding-and-designing-usabl
Daniel Downs
 
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Form using html and java script validation
Maitree Patel
 
Ad

More from Russ Weakley (20)

PDF
Accessible chat windows
Russ Weakley
 
PDF
Accessible names & descriptions
Russ Weakley
 
PDF
A deep dive into accessible names
Russ Weakley
 
PDF
What are accessible names and why should you care?
Russ Weakley
 
PDF
How to build accessible UI components
Russ Weakley
 
PDF
What is WCAG 2 and why should we care?
Russ Weakley
 
PDF
Accessible states in Design Systems
Russ Weakley
 
PDF
Creating accessible modals and autocompletes
Russ Weakley
 
PDF
Building an accessible progressive loader
Russ Weakley
 
PDF
Accessibility in Design systems - the pain and glory
Russ Weakley
 
PDF
What is accessibility?
Russ Weakley
 
PDF
Accessibility in Pattern Libraries
Russ Weakley
 
PDF
Accessibility in pattern libraries
Russ Weakley
 
PDF
Building an accessible auto-complete - #ID24
Russ Weakley
 
PDF
Building an accessible auto-complete
Russ Weakley
 
PDF
Creating Acessible floating labels
Russ Weakley
 
PDF
Creating a Simple, Accessible On/Off Switch
Russ Weakley
 
PDF
Accessible custom radio buttons and checkboxes
Russ Weakley
 
PDF
Deep Dive into Line-Height
Russ Weakley
 
PDF
Building Accessible Web Components
Russ Weakley
 
Accessible chat windows
Russ Weakley
 
Accessible names & descriptions
Russ Weakley
 
A deep dive into accessible names
Russ Weakley
 
What are accessible names and why should you care?
Russ Weakley
 
How to build accessible UI components
Russ Weakley
 
What is WCAG 2 and why should we care?
Russ Weakley
 
Accessible states in Design Systems
Russ Weakley
 
Creating accessible modals and autocompletes
Russ Weakley
 
Building an accessible progressive loader
Russ Weakley
 
Accessibility in Design systems - the pain and glory
Russ Weakley
 
What is accessibility?
Russ Weakley
 
Accessibility in Pattern Libraries
Russ Weakley
 
Accessibility in pattern libraries
Russ Weakley
 
Building an accessible auto-complete - #ID24
Russ Weakley
 
Building an accessible auto-complete
Russ Weakley
 
Creating Acessible floating labels
Russ Weakley
 
Creating a Simple, Accessible On/Off Switch
Russ Weakley
 
Accessible custom radio buttons and checkboxes
Russ Weakley
 
Deep Dive into Line-Height
Russ Weakley
 
Building Accessible Web Components
Russ Weakley
 
Ad

Recently uploaded (20)

PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
PPTX
Different types of inheritance in odoo 18
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
PPTX
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
DOCX
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
AIMA UCSC-SV Leadership_in_the_AI_era 20250628 v16.pptx
home
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Lesson 1 - Nature of Inquiry and Research.pdf
marvinnbustamante1
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Lesson 1 Cell (Structures, Functions, and Theory).pptx
marvinnbustamante1
 
Different types of inheritance in odoo 18
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
SD_GMRC5_Session 6AB_Dulog Pedagohikal at Pagtataya (1).pptx
NickeyArguelles
 
Marketing Management PPT Unit 1 and Unit 2.pptx
Sri Ramakrishna College of Arts and science
 
Lesson 1 - Nature and Inquiry of Research
marvinnbustamante1
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PLANNING FOR EMERGENCY AND DISASTER MANAGEMENT ppt.pptx
PRADEEP ABOTHU
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
AIMA UCSC-SV Leadership_in_the_AI_era 20250628 v16.pptx
home
 

Accessible Inline errors messages