Required Form Elements

Overview

Required fields are commonly identified with an asterisk.

However, the asterisk character is typically not announced by screen readers.

Following are techniques to use in order to notify screen reader users that form elements are required to complete.


Required Form Input Field

Make the form element mandatory to complete by applying the “required” attribute to the input tag.

By default, when a form element has been marked as required and receive keyboard focus, the screen reader will announce the form element as “required invalid”.

The form element should be announced as invalid only after it has lost keyboard focus.

Add the “aria-invalid=”false” attribute to the default state to prevent screen readers from announcing the form element as invalid.

When the form input field has keyboard focus: 

  •  the screen reader should announce/notify the user that it is a required field

  • the screen reader should NOT announce that it is an invalid entry, the form element should be announced as invalid after it has lost keyboard focus

Markup

<label for="fname">First Name:</label> <input id="fname" required required aria-invalid="false">

View HTML Markup on Github


Required Group of Radio Buttons

When the legend is announced by the screen reader: 

  •  it should notify the user that it is a required form element

Markup

Add an invisible required label, within the legend tag.  that will be announced by the screen reader.

A sighted user will not see this text.

<fieldset> <legend>Select your shipping option:<span class="required">required</span></legend> <input id="overnight" type="radio" name="shipping" value="overnight"> <label for="overnight">Overnight</label><br> <input id="twoday" type="radio" name="shipping" value="twoday"> <label for="twoday">Two day</label><br> <input id="ground" type="radio" name="shipping" value="ground"> <label for="ground">Ground</label> </fieldset>

CSS

.required { display: none; }

View HTML Markup on Github


Required Group of Checkboxes

Add an invisible required label, within the legend tag.  that will be announced by the screen reader.

A sighted user will not see this text.

When the legend is announced by the screen reader: 

  •  it should notify the user that it is a required form element

Markup

CSS

View HTML Markup on Github


Required Single Checkbox

You can make standalone/single checkboxes mandatory to complete by applying the “required” attribute to the input tag.

By default, when a form element has been marked as required and receive keyboard focus, the screen reader will announce the form element as “required invalid”.

The form element should be announced as invalid only after it has lost keyboard focus.

Add the “aria-invalid=”false” attribute to the default state to prevent screen readers from announcing the form element as invalid.

When the checkbox has keyboard focus: 

  • the screen reader should announce/notify the user that it is a required field

  • the screen reader should NOT announce that it is an invalid entry, the form element should be announced as invalid after it has lost keyboard focus

Markup

View HTML Markup on Github