Skip to content

FRM-002a Show a field's error as text at the field

Level
Rule
Verdict
Unanimous (2 of 2)
Area
Forms
Status
decided, version 1.0.3

Rule

When a field or a group of inputs has an invalid value, show the error as visible text at that field, and never only in a banner, a dialog or a tooltip somewhere else.

Examples

Live examples built with Justified's components. Try them with the mouse, the keyboard or a screen reader.

Do: The error at the field

Error: This email address already has an account. Sign in or use a different address.

The server sent the form back. The message sits at Email address, says what is wrong and what to do, and is read out with the field. Change the address and press Create account.

Don't: A banner and a red outline

The form contains errors.

The banner says something is wrong but not what, and the red outline does not say it either. A screen reader moving to the field hears only that it is invalid, not why.

Why

People correct a value where the value is. If the message lives in another place, they have to remember it, scroll between the two, or guess which field it means, and the message may be gone by the time they start typing. Placing it at the field and tying it to the control in code means sighted and screen reader users meet the problem and the field together. WCAG 2.2, 3.3.1 Error Identification asks that the field in error is named and the problem is described in text, but it leaves the place open (see Understanding 3.3.1). This rule is our design choice for that place.

Do

  • A field labelled "Postcode" holds "1234". Right at the field, the text "Enter a five-digit postcode, for example 11359." appears with an error icon, and stays there while the person edits.
  • A bank account entered as a branch code box and an account number box gets one message for the pair. If only the branch code is wrong, the message says so: "The branch code must be four or five digits".
  • The server sends the form back because the email address is already registered. The message "This email address already has an account. Sign in or use a different address." is shown at the email field, not only at the top.
  • You add a summary at the top of a long form as an extra. Each line in it links to its field and uses the same words as the message at that field.
  • The control points to its message with aria-describedby and is marked with aria-invalid, so the message is read out with the field. Justified's Field component does this for you.
  • An end date comes before a start date. Show the message at the end date, since that is the field people most often change. This is our own choice for errors that involve two fields.

Don't

  • Show only a banner that says "The form contains errors" and leave the person to find the fields.
  • Put the message behind an icon that reveals it on hover or focus.
  • Open a dialog with the error that must be closed before the person can fix the value.
  • Mark the field with a red outline and nothing else. Always add text, and an icon if you like.
  • Place the text visually next to the field but leave it unlinked in code, so a screen reader reads the field without its error.

Exceptions

  • Problems that are not about a value the person entered, such as a service that is down, missing permission or not being eligible, do not belong at a field. Show them as a message for the page or the form instead.
  • This rule does not set whether the message goes above or below the input, or whether it replaces the hint text. Both are left to the component. If the message does take the place of the hint, it must repeat whatever the hint said that the person needs to fix the value.
  • When the error appears is covered by FRM-002b.
  • What a free-text field says when its length limit is reached or passed is the guideline FRM-017c. An error for text that is too long still shows at the field, as this rule asks.

Verdict

Unanimous (2 of 2). Only the judges decide; the expert witnesses are shown but do not vote. How verdicts work

Stances on FRM-002a
SourceRoleStancePage
WCAG 2.2LawSupports3.3.1 Error Identification
WCAG 2.2LawSupports3.3.3 Error Suggestion
WCAG 2.2LawSupports1.3.1 Info and Relationships
WCAG 2.2LawSupports1.4.1 Use of Color
WCAG 2.2LawSupports4.1.2 Name, Role, Value
Material DesignJudge SupportsText fields: guidelines
Text fields: accessibility
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge SupportsForms
Text input: usage
GOV.UK Design SystemExpert witness SupportsError message
Recover from validation errors
Error summary
Nielsen Norman GroupExpert witness Supports10 Design Guidelines for Reporting Errors in Forms, by Rachel Krause

Each stance links to the page it rests on, read on the date in the source register. This page never repeats what a source says; read the source itself.

History

  • Version 1.0.3, : Refers to FRM-017c for what a free-text field says at its length limit.
  • Version 1.0.2, : Examples in English.
  • Version 1.0.1, : The example for an address that already has an account now gives a next step, as TXT-001a asks.
  • Version 1.0.0, : First version.

Last checked against the other rules for conflicts on .

More in Forms: 15 rules and 12 guidelines · All rules