Skip to content
easeweb
Search topics

Form errors that don't say how to fix them

A failed sign-up turns the email field red, or says only "Invalid email address", so nothing in words says what to enter instead.

WCAG 2.2
SC 3.3.1ASC 3.3.3AA
Required by
Section 508 · EN 301 549 (EU)
Broken email.classList.add('invalid');
The accessibility problem illustrated: Colour vision:What's wrong?
01

The problem

People see that something went wrong, but not what to change

02

Try it

Type “name@”, press Subscribe, and find out what to fix

  • Broken 1: after Subscribe, is anything said in words? Press Shift + Tab to go back to the field: what does the screen reader say?

  • Broken 2: a message appears and is read with the field. Does it tell you what to type instead?

  • Apply a fix. Each one says what to enter. With aria-errormessage, see what a screen reader without support for it says. With the browser’s own check, the message is the browser’s bubble, for one field at a time.

Broken Can you fix this?

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Say beside the field what to enter, and tie it to the field

Before

An error shown only by a red border

<form id="signup" novalidate>  <label for="email">Email address</label>  <input id="email" name="email" type="email" autocomplete="email" required>  <button>Subscribe</button></form>
What is wrong4 points

The field has its label, and the page's check finds the mistake. Showing it is where this fails.

  • People who can't tell the red from the grey may not notice the error at all. Its only sign is the invalid class, which paints the border red.
  • Nothing in text says the field is wrong, or what to enter instead.
  • A screen reader reads the field just as it did before the send. Its markup doesn't change, so there is no message to read with it.
  • The browser's own message doesn't appear either. novalidate turns it off, because the page checks the field with its own script, as many sign-up forms do.
After

A message tied with aria-describedby

<form id="signup" novalidate>  <label for="email">Email address</label>  <input id="email" name="email" type="email" autocomplete="email" required    aria-describedby="email-error">  <p id="email-error"></p>  <button>Subscribe</button></form>
How it is fixed4 steps
  1. Write one message for each problem the check can find, each saying what to enter: "Enter your email address." for an empty field, and "Enter an email address, such as [email protected]." for one that isn't an address. The example shows the part that was missing.
  2. Put the message in a paragraph under the field, and point the field's aria-describedby at it, so it is read after the field's name.
  3. Set aria-invalid="true" along with the message, and move focus to the field, so a screen reader reads the name, the invalid state and the message together.
  4. When the value passes, empty the paragraph and remove aria-invalid, so no old error is left behind.

This fixes both Befores and passes 3.3.1 and 3.3.3. The red border stays, now with the words beside it. On a form with one field, moving focus to it is enough; with more fields, add the error summary described below.

Easily confused
04

Design ideas

An error can be red and still say what to fix

Four ways to draw the same email field after a failed sign-up. Read each one in greyscale, and press Subscribe beside the last: two say what to change, and two show only that something is wrong.

In the design file

  • Write what to fix, not just that something is wrong. For example, “Enter an email address, such as [email protected].”
  • Add an icon or the word “Error” next to the red, so the error still shows in greyscale and in a contrast theme.
  • For a form with several fields, draw a list of the errors at the top, each linking to its field.
  • Write the red text’s contrast ratio next to its colour, at least 4.5:1 on every background it sits on. The example’s red has 6.54:1 on white.

Passes

  • Enter an email address, such as [email protected].

    Message between the label and the field A 4px #b3261e bar down the side of the group, and the message in bold between the label and the field, where the GOV.UK Design System puts it: people read what to fix before they reach the field.
  • Enter an email address, such as [email protected].

    Message in a tray joined to the field The message sits in a tinted tray joined to the bottom of the field, #b3261e on #fbe9e7 at 5.58:1, so the field and what to fix read as one block.

Fails

  • Invalid
    An “Invalid” tag inside the fieldWCAG 3.3.3 A neat tag in the field names the error in text, but not the fix. The fix is known, an address needs a domain after the @, so 3.3.3 asks for it: “Enter an email address, such as [email protected].”
  • A field that shakes, with no messageWCAG 3.3.1 Press Subscribe: the field shakes three times in under half a second and turns red, with no words. Anyone looking elsewhere misses it, and with reduced motion, which stops the shake, only the colour changes.
05

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Forced colors

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared form component, or its schema library, changes.

How screen readers handle aria-describedby, aria-invalid="true" and aria-errormessage

Limits

This is a starting pattern, not a guarantee for every application. It covers the message at one field after a failed send. The list of errors at the top of a longer form is covered in error summaries that don't say which fields failed; when an error is said while people type, in inline form errors read out while typing, or not at all; marking which fields are required before anyone sends, in required fields marked only by colour; and announcing the result of a send, in form success and error messages that are never announced. Test the complete journey with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service