[Draft] Module 5: Forms and Input Elements
Introduction
Courses based on this module:
- explain use of HTML elements to:
- label form elements
- group form elements that share a common purpose
- provide instructions for users to fill in forms in the expected way
- explore strategies that people with disabilities use to interact with and fill in forms
Learning Outcomes for Module
Students should be able to:
- label controls so that they can be understood by users and assistive technologies
- group form elements that share a common purpose
- provide instructions that help understand form elements’ purpose
- notify users of errors or successes during and after form completion
- explain how some users navigate, fill in, and perceive information from form elements
Competencies
Skills required for this module.
Students:
- Completion of courses that include:
- Basic knowledge of:
Instructors:
- Applied expertise in teaching:
- WCAG 2 Success Criterion 1.3.1 Info and Relationships
- WCAG 2 Success Criterion 1.3.5 Identify Input Purpose
- WCAG 2 Success Criterion 2.2.1 Timing Adjustable
- WCAG 2 Success Criterion 2.4.6 Headings and Labels
- WCAG 2 Success Criterion 3.2.2 On Input
- WCAG 2 Success Criterion 3.3.1 Error Identification
- WCAG 2 Success Criterion 3.3.2 Labels or Instructions
- WCAG 2 Success Criterion 3.3.3 Error Suggestion
- WCAG 2 Success Criterion 4.1.2 Name, Role, Value
- WCAG 2 Success Criterion 4.1.3 Status Messages
- HTML forms
- HTML elements
form
,label
, andinput
- HTML element
Button
- HTML elements
fieldset
andlegend
- Common input element attributes
- Date, time, and input formats
- In-depth knowledge of:
Topics to Teach
Optional topics to achieve the learning outcomes.
Topic: Form Labels
Explain use of HTML elements and WAI-ARIA attributes to label form elements and make them understandable. For example, the label
element and the `for attribute.
Explain how clear labels, instructions, and large text targets allow people to navigate, understand, and fill in form elements.
Learning Outcomes for Topic
Students should be able to:
- mark up labels for form elements using the
label
element - code labels and input fields associations using the HTML attribute
for
, the HTML elementtitle
, or the WAI-ARIA attributesaria-label
oraria-labelledby
- mark up several form elements that share the same purpose using the HTML elements
fieldset
andlegend
- mark up additional instructions for form elements using the HTML element
title
, or the WAI-ARIA attributearia-describedby
- explain how labels allow people using text-to-speech technologies to identify and fill in form elements
- explain how larger targets allow people with low vision or cognitive disabilities to interact with form elements
Teaching Ideas
Optional ideas to teach the learning outcomes:
- Provide examples of explicit and implicit associations using the
label
element. Explain that an implicit association can be achieved by wrapping thelabel
element and its content around the form element. Explain explicit associations by means of thefor
attribute, and indicate that its value must be a unique id reference of the form element that the label refers to. Explain use of other explicit associations using the WAI-ARIA attributesaria-labeled
oraria-labelledby
. For reference on how to label form elements, see the WAI website tutorials Labeling controls. - Show examples of form elements that are related to each other, such as check boxes or radio buttons to select possible answers for a given question. Mention that the
fieldset
element is used to group them all, and that thelegend
element provides the label they share. For reference on how to group form elements, see the WAI website tutorials Grouping controls. - Show examples of additional instructions for form elements provided using the HTML attribute
title
, or the WAI-ARIA attributesaria-label
, oraria-labelledby
. Mention thattitle
may not be well supported by some assistive technologies. Emphasize that contents provided using WAI-ARIA are available for assistive technologies only and are not visible on screen. For reference on additional methods to provide labels for form elements, see technique H65: Using the title attribute to identify form controls when the label element cannot be used. - Invite students to navigate form elements using the keyboard only. Demonstrate use of the tab key to move through different form elements. Demonstrate use of the arrow keys to select options from combo boxes or lists.
- Demonstrate use of commands, keystrokes, or gestures of text-to-speech technologies to move to next or previous form element. Explore advanced functionality which presents all form elements in a list where users can select the form element they are interested in. For reference on how people with disabilities interact and navigate web pages, see Stories of Web Users.
- Demonstrate how users with mobility impairments or low vision users can click the label element to activate a specific form element if both are associated with each other.
Ideas to Assess Knowledge
Optional ideas to support assessment.
- Short answer questions — Students are asked to recite different ways to label form elements using HTML. Assess students’ knowledge of the different HTML ways to label form elements.
- Practice — Students are presented with a group of form elements and are asked to provide their labels. Assess how students make use of the HTML element
label
together with the HTML attributefor
, the HTML attributetitle
, or the WAI-ARIA attributesaria-label
, andaria-labelledby
. - Practice — Students are presented with a set of radio buttons that allow to rate a piece of content based on stars, and a piece of text saying, “Rate this”. Students are asked to properly associate them with their overall label. Assess how students use the HTML elements
fieldset
andlegend
. - Practice — Students are asked to activate a set of form elements by clicking their labels. Assess how students understand the relevance of proper click targets for users with mobility impairments.
Topic: Input Validation
Explain how HTML5 input types and validation techniques allow people with disabilities to enter information in forms easier and in a more predictable way. For example, date
, time
, or url
.
Learning Outcomes for Topic
Students should be able to:
- mark up required form elements using text or the HTML attribute
required
- code specific types of data with their corresponding HTML5 input type. For example,
date
,time
,url
, oremail
- code common regular expressions using the HTML attribute
pattern
Teaching Ideas
Optional ideas to teach the learning outcomes:
- Show examples of required form elements using the HTML attribute
required
or some added text in the label. For reference on how to validate required input, see the WAI website tutorials Validating required input. - Demonstrate use of some common HTML5 elements, such as
date
,time
,url
, oremail
. Explain that they allow users to enter data more reliably and help validation. For reference on how to validate common input, see the WAI website tutorials Validating common input. - Show examples of the HTML attribute
pattern
with regular expressions to validate common ways of entering information, such as country codes, phone numbers, or dates.
Ideas to Assess Knowledge for Topic
Optional ideas to support assessment.
- Practice — Students are presented with a set of form elements and are asked to communicate that they are required. Assess how students make use of the HTML attribute
required
and/or some text in the label of the form element. - Practice — Students are presented with a set of form elements to collect date, time, url, and email data. Students are asked to choose an HTML5 input type that serves the specific purpose of each of the form elements. Assess students’ knowledge of HTML5 form input types.
- Practice — Students are presented with form elements that collect phone numbers of a given country as well as dates of birth. Students are asked to use the
pattern
element and common regular expressions to specify custom input formats. Assess how students use thepattern
attribute together with regular expressions to validate the expected input format.
Topic: User Notifications
Explain use of HTML and WAI-ARIA elements to notify users about successes, errors, or any other warning messages resulting from their input or from a time limit. For example, headings, additional label texts, and aria-live regions.
Learning Outcomes for Topic
Students should be able to:
- notify users of existing time limits
- provide mechanisms to stop or extend time limits
- provide information about the amount of errors in the main heading of the page, the page title, or via modal dialogs
- associate error messages with their corresponding form elements using headings, lists, or anchors
- provide inline feedback through messages belonging to specific form elements via labels, icons, or the
aria-describedby
attribute - provide instant feedback as the user is typing using
aria-live
regions
Teaching Ideas for Topic
Optional ideas to teach the learning outcomes:
- Mention that time limits in forms should be avoided to allow users to complete them at their own pace. Explain that when there is a compelling reason to establish the limit, users must be notified in advance and be provided with a way to extend or stop the limit. If the time limit is essential to a valid submission, then there is no need to allow users to extend or stop the limit. For reference about how to provide mechanisms to stop or extend time limits, see technique G180: Providing the user with a means to set the time limit to 10 times the default time limit.
- Introduce the different ways in which errors can be announced after form submission. Explain that a warning message should be included in the title of the page or its main heading, so that all users are aware that their submissions have produced errors. For reference on how to communicate error messages, see the WAI website tutorials, Overall feedback.
- Demonstrate use of mechanisms to provide inline error messages for form elements so that users can relate them to its specific field as they move around. Explain that you can use the
label
element to include that information or use thearia-describedby
attribute. Explain that WAI-ARIA live regions can be used to provide instant feedback as users are typing in a form element or as validation outputs appear so that screen reader users can understand the information provided. For reference on how to provide inline error messages, see the WAI website tutorials, In-line feedback.
Ideas to Assess Knowledge for Topic
Optional ideas to support assessment.
- Practice — Students are presented with a page where there are form elements visually marked with errors. Students are asked to
- Indicate the presence of these errors in the main heading or title of the page.
- Make textual reference to each erroneous field and group those references in a list.
- Link each list item with its corresponding form element.
- Provide inline instructions in the corresponding form element that users will read once the form element gets focus.
Ideas to Assess Knowledge for Module
Optional ideas to support assessment.
- Short answer questions — Students are asked how labels and instructions allow people with disabilities to fill in form elements. Assess students’ understanding of properly coded form label and instructions.
- Portfolio — Students add a set of form elements to the website they are building. Assess how students identify, label, group form controls as wells as how they provide feedback based on users’ input.
Teaching Resources
Suggested resources to support your teaching:
- WAI Web accessibility Tutorials — Shows how to develop web content that is accessible to people with disabilities.
- How People with Disabilities Use the Web — Provides stories of people with disabilities using the Web; describes types of disabilities and some of the barriers that people encounter using the Web; and introduces types of assistive technologies and adaptive strategies that some people use.
- HTML specification — The core markup language for the web, HTML, as well as numerous APIs like Web Sockets, Web Workers, localStorage, etc.
- WCAG — Address accessibility of web content on desktops, laptops, form elements, and mobile devices.
- WAI ARIA — Provides an ontology of roles, states, and properties that define accessible user interface elements and can be used to improve the accessibility and interoperability of web content and applications.
- Notifications and Feedback — Is one of the Web accessibility perspectives videos that show accessibility features and how they impact people with disabilities.