Skip to content

FRM-011 When a form is sent with problems, move focus to the first problem or to a summary of them

Level
Guideline, our choice
Verdict
Insufficient evidence (0 of 3 judges spoke)
Area
Forms
Status
proposed, version 1.0.0

Rule

When a form is sent and problems are found at its fields, in the browser or by the server, move focus to the first field with a problem, or to a summary above the form that links to each problem. This holds for every form: short or long, page or dialog, and each step of a multi-step form.

Examples

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

Do: Focus goes to the problems, or to the one problem

Book a kennel stay

Press Book stay with the three empty fields. Focus moves to a box that counts the problems, and each line links to its field, in the order of the form. Follow one link, fill in two fields and press again: with one problem left, focus goes straight into that field. Every field also shows its own message, and nothing is read twice.

Don't: The messages appear and focus stays on the button

Book a kennel stay

Press Book stay. Messages show at the three fields, which may be far above, but focus stays on the button and nothing is announced for that send, so a screen reader user hears nothing and has to search the form. Keeping focus on the button would only be fine if each message were announced instead.

Why

The person who sends a form is at the button, at the end of the form. The problems are somewhere above. A sighted person may see red text appear, if it is on screen. A screen reader user hears only what has focus, and a keyboard user has to tab backwards through the form to find what went wrong. Moving focus on that press takes them to the problem, or to a list of the problems, so the next step is plain. The press is the person's own request, so the move answers it and does not come as a surprise. Focus moves only when the form is sent. An error that appears when the person leaves a field keeps focus where it is, as FRM-002b says. No WCAG criterion asks for focus to move. WCAG 2.2, 3.3.1 Error Identification asks that a detected problem is pointed out and described in text, and leaves the way open. Moving focus is one way to make the problems known. The other is to keep focus still and announce the messages, which 4.1.3 Status Messages then requires and FBK-004 covers. One criterion bears on how the move is made, not on whether it is made: from the place focus lands, Tab goes on in an order that makes sense (2.4.3 Focus Order). That the landing place shows its focus indicator and is not covered is asked by KBD-001 and KBD-002, as for any focused element.

Our reasons

Fewer than two judges have spoken about where focus goes when a form is sent with problems; in fact none has. The verdict is therefore Insufficient evidence, and this guideline is our choice. One expert witness, GOV.UK, supports it, and a witness does not vote. Its support is for the summary. Moving focus straight to the first field with a problem has no judge or witness behind it; it is our own alternative. We move focus at all, and allow both ways, for five reasons.

  • Silence looks like a broken form. If the messages appear and focus stays on the button, a screen reader user hears nothing new. They cannot tell a refused form from a slow one or a dead button, and some will press again or give up.
  • The problem may be out of view. On a long form, or a short one zoomed to 400 percent, the field in error can be off screen when the button is pressed. Focus brings it into view. The person does not have to scroll and search.
  • Landing on the problem is the start of the fix. In the field, the person can type the correction at once. On the summary, they see how much there is to do and can pick where to begin.
  • One behaviour for every form is easier to learn and to build. A product whose long forms move focus and whose short forms do not asks people to guess which kind they are in. So we do not make this depend on the form's length.
  • With one problem, a summary is an extra step. The person lands on a list of one line and follows its link to the field. That is why we also allow focus to go straight to the field. Browsers' own form checking also puts focus in the first field that fails, so many people have met that behaviour. This is our observation about browsers, not a source's advice.

Do

  • A page form Book a kennel stay has Pet's name, Arrival date, Collection date, Feeding notes and Vet's phone number. The person presses Book stay with Arrival date empty. The field shows "Enter the date your pet arrives, for example 2027-03-14", and focus moves into Arrival date. Because the message is tied to the field in code, as FRM-002a says, a screen reader reads the field's name and its message together.
  • The same form is sent with three problems. A box above the form has the heading "Check 3 answers before you book" and takes focus. Each line in it is a link to its field, in the words of the message at that field: "Enter the date your pet arrives, for example 2027-03-14" goes to Arrival date. Make the box able to take focus from code, for example with tabindex="-1", and let its heading be read when focus lands.
  • Every field with a problem still shows its own message, all in the same round. Where the message sits is FRM-002a, and that sending reveals every field's error at once is FRM-002b. What the person entered is still in the fields, as FRM-009 says.
  • Our own advice: when there are several problems, prefer the summary. Focus on one field tells a screen reader user about that field's problem only. Focus on the summary tells them about all of them.
  • Do not let the messages be read twice. When focus moves to a field, turn off that field's live announcement for that moment, as FBK-004 says. When focus moves to a summary, hold back the fields' live announcements for that round too; the summary has already said the same words. That second point is ours.
  • "First" means first in the order of the form. Arrival date comes before Vet's phone number on the page, so focus goes to Arrival date, even if the phone number was checked first.
  • Focus, or the summary's link, goes to the input the person has to change. When one answer is made of several inputs and the product cannot tell which of them that is, it goes to the first input of the answer. Vet's phone number is a country code list and a number box, and the number box holds four digits: the target is the number box, not the list before it. Applying this to focus that goes straight to the field is our own detail.
  • A short form counts too. The dialog Add a pet has only Name and Species. The person presses Add pet with Species not chosen. The dialog stays open, "Choose a species" shows at the field, and focus moves to the first option of Species, inside the dialog. A summary, if the product uses one, also sits inside the dialog.
  • Step 2 of 3, Food and medicine, has a Next button. Pressing it sends that step. With Meals per day empty, the step stays, the field shows "Enter how many meals your pet has each day", and focus moves there.
  • The server sends the form back because of a voucher. Voucher code shows "The code SPRING5 ended on 1 March. Remove it or enter another code." Focus moves to Voucher code or to the summary, the same way as when the browser finds the problem.
  • When the form comes back as a new page, the page sets focus itself once it has loaded. A reloaded page otherwise starts at the top, and the move is lost.
  • Check the landing place. The field or the summary scrolls into view and is not hidden under a sticky header, as KBD-002 requires, and the focus indicator shows on it, as KBD-001 says. From the summary, Tab goes to its links and then on into the form.
  • A product may pick one way for all its forms, always the summary or always the first field, or use the first field for one problem and the summary for several.

Don't

  • Show the messages and leave focus on Book stay, so a screen reader user hears nothing and has to search the form.
  • Skip the move on the two-field dialog Add a pet because everything is on screen. A screen reader user does not see the screen.
  • Move focus to the top of the page or to the page heading. Neither is a problem nor a summary.
  • Move focus to the last field with a problem, or to the one whose check happened to finish first.
  • List the problems in the summary as plain text with no links, so the person still has to find each field.
  • Let the summary stand in for the messages at the fields. FRM-002a asks for those in every case.
  • Close the dialog Add a pet when it is sent with problems, or move focus to the page behind it.
  • Move focus to Arrival date and also announce its message from a live region, so "Enter the date your pet arrives" is read twice.
  • Move focus to a field's error when the person leaves that field. Focus moves only when the form is sent.
  • Reload the page with the problems marked and leave focus at the top of the document.

Exceptions

  • A problem that belongs to no field. When the booking system does not answer, or the person has been signed out while filling in the form, there is no field to go to. Where that failure is shown, and what follows, is left to FBK-002. This guideline covers problems at fields.
  • A button that is unavailable. When a short form keeps its button off until the required input is in, as ACT-004 leaves open for short forms, with the note ACT-005 asks for, the form cannot be sent with those problems and this guideline has nothing to act on. A problem only the server can find still comes back, and then it applies.
  • Passwords. A password field may come back empty after a refused send, as FRM-009 allows. Focus still goes to the first problem or to the summary.
  • A product that keeps focus still. This is a guideline, and a product may choose otherwise. If focus does not move, every message that appeared is a status message and FBK-004 applies to it in full.
  • Other rules. Whether the button is enabled is ACT-004 and ACT-005. What the button does between the press and the reply is STA-005a and STA-005b. Where a message sits is FRM-002a, when it appears and clears FRM-002b, its words TXT-001a, and how a message is announced when it does not take focus FBK-004.

Verdict

Insufficient evidence (0 of 3 judges spoke). Only the judges decide; the expert witnesses are shown but do not vote. The judges do not settle this one, so it is a guideline: our own choice, with our reasons above. How verdicts work

Stances on FRM-011
SourceRoleStancePage
WCAG 2.2LawSupports3.3.1 Error Identification
WCAG 2.2LawSupports4.1.3 Status Messages
WCAG 2.2LawSupports2.4.3 Focus Order
Material DesignJudge No position
Apple Human Interface GuidelinesJudge No position
Carbon Design SystemJudge No position
GOV.UK Design SystemExpert witness SupportsRecover from validation errors
Error summary
Nielsen Norman GroupExpert witness No position

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.0, : First version. Takes over what happens when a form is sent with problems from ACT-004, and covers every form.

Last checked against the other rules for conflicts on .

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