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.
email.classList.add('invalid'); The problem
People see that something went wrong, but not what to change
A newsletter sign-up asks for an email address. Someone types "name@", leaving out the part after the @, and presses Subscribe. The page stays where it is and keeps what they typed. What it tells them next depends on how the form was built, and two ways are common.
In the first, the field's border turns red, and that is all. Nothing in words says the field is wrong, or that the address is missing its domain. A screen reader user who goes back to the field hears its name and "name@", and nothing in words about what is wrong: in Chrome, "Email address, edit text, required, name@".
In the second, a line appears under the field: "Invalid email address". It is tied to the field, and the field is marked invalid, so a screen reader reads "Email address, invalid entry, edit text, required, name@, Invalid email address". Everyone now knows which field is wrong. Nobody is told what an email address needs: the person who typed "name@" thought they had typed one.
Success criterion 3.3.1 Error Identification asks that when an input error is detected automatically, the item in error is identified and the error is described to the user in text. In the first version, the page's own script finds the error and shows it only as a red border, drawn from a class that only the stylesheet reads. Its Understanding page is plain: "The error must be indicated in text." Colour may mark the error too, but not alone; W3C's failure F81 describes the same field from the side of 1.4.1, an error field marked by colour only. A screen reader has no text to read, and the field's markup is the same as before, so it isn't even read as invalid.
The second version passes 3.3.1: the message is text, it sits under the field and is tied to it. Success criterion 3.3.3 Error Suggestion goes one step further. When an error is detected automatically and suggestions for correcting it are known, they are given, unless that would put security or the purpose of the content at risk. Here the correction is known: the check is the browser's own rule for type="email", which wants text on both sides of the @, and the script reads its answer. "Invalid email address" says that the value fails and nothing about what would pass. It is the default message of z.email() in the schema library Zod, and the GOV.UK Design System advises leaving "valid" and "invalid" out of error messages "because they do not add anything to the message". The browser's own message for a pattern falls short the same way: in Chrome it asks only that the value match the requested format, and the Understanding page for 3.3.1 warns that the browser's default messages "may not provide sufficiently helpful or specific suggestions".
Sign-up, checkout and account forms are where people meet this, at the moment they most need the page to speak to them: they did what they thought was right, and now need to be told what to change.
4 of 10 groups affected
- No vision (affected)
- Low vision (affected)
- Colour vision (affected)
- No hearing (not affected)
- Hard of hearing (not affected)
- No speech (not affected)
- Motor (not affected)
- Reach, strength (not affected)
- Cognitive (affected)
- Seizures (not affected)
- Without vision With a red border alone, the field is read exactly as before it was sent. With "Invalid email address" tied to it, screen reader users hear that it is wrong, but not what to type instead.
- Without perception of colour With a red border alone, people who can't tell the red from the grey may not notice that the sign-up failed at all, or which field to change.
- Limited vision With a red border alone, people with low vision may not see the edge change from grey to red, and nothing else marks the field in error.
- Limited language, cognitive and learning abilities "Invalid email address" says something is wrong without saying what. People who don't know that an address needs a domain after the @ can't tell how to put it right.
A scan of the page as it loads finds a labelled field and nothing wrong: both failures appear only after a send. EaseWeb's audit reports a field marked aria-invalid="true" with no message tied to it (ew:invalid-without-message). On the tester's own site, Readout's Full check and the audit's --send-forms also send each empty form, then send it again with "name" typed into an email field, and list each message the page showed and whether it is tied to its field. Each of those messages goes to the AI review, which is asked whether it says which field is wrong and how to put it right; "Invalid email address" after "name" is the kind it is asked to flag. Neither Before trips a rule on its own. The red border changes no text and no attribute a check reads, so the send finds no message on the page, and only a person looking at the field sees the red. The second Before has every attribute a scan looks for. An AI assistant asked to make the errors accessible can add aria-invalid and aria-describedby around the message that is there, which turns the first Before into the second: the markup passes, and the words still don't help.
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?
The fix
Say beside the field what to enter, and tie it to the field
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
invalidclass, 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.
novalidateturns it off, because the page checks the field with its own script, as many sign-up forms do.
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
- 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.
- Put the message in a paragraph under the field, and point the field's
aria-describedbyat it, so it is read after the field's name. - 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. - 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.
Why this fix: Show a message next to what it is about
All three put the error in words beside the field and say what to enter. Use the message tied with aria-describedby: it is read with the field by screen readers that read descriptions, stays on the page until the value is corrected, and is styled by you, while the other two each leave some people out. aria-errormessage says more exactly what the text is, an error that applies only while the field is invalid, and is a choice once the screen readers your users have support it. The browser's own check is the least code; it suits a short form, one field or two, where finding mistakes one at a time costs little, and it still needs your words.
When a form can fail in more than one field, also put an error summary before the fields that links to each problem; error summaries that don't say which fields failed shows how. On a form with a single field, moving focus to that field after a failed submission is enough. Don't move focus on every keystroke, and don't pair forced focus with several assertive announcements: repeating the same error makes the form harder to understand.
Validate again on the server, and return its errors to the field they belong to, in the same words and tied the same way: "This email address is already registered" is a field error too. Return the entered values, and escape them before inserting them into HTML. Never refill a password or other sensitive field merely to preserve a form.
When submission succeeds, replace the error state with a clear confirmation. If the confirmation updates the current page without moving focus, an appropriate status region can announce the result.
Word each message for its field. The message isn't always read beside its field: it is read after the field's name, in an error summary, or after the next field's name when it appears as people leave. So it has to make sense on its own.
- Say what to do, not what is wrong with the person: "Enter an email address, such as [email protected]", not "Invalid email address" or "You entered an invalid email".
- Write one message for each problem. An empty field and a wrong format need different words, and a message that covers both helps with neither.
- Use the words of the field's label, so the message says which field it is about wherever it is read.
- Give an example in the format the field takes, or the limit it has: "Enter a number from 1 to 12".
- Hold back only what security needs. 3.3.3 makes an exception for that, so a sign-in form may say that the email address or password is wrong without saying which.
Replace library defaults. Schema libraries ship placeholder messages: "Invalid email address" in Zod, and "email must be a valid email" in Yup, with the field's key where its label should be. Pass your own message for each rule in the schema rather than showing the default.
More than colour. Keep the red if the design has it, and add the words, an icon or the word "Error". A message in red text needs 4.5:1 against its background.
Not before the form is sent. Don't render a field with aria-invalid="true" because it is empty and required: screen readers read "invalid entry" on a field nobody has touched. When an error appears while people type, rather than when they send, the moment it is said matters as much as its words; see inline form errors read out while typing, or not at all.
Not in a toast or a tooltip. A message in a toast in a corner names no field and is gone before a magnifier user pans to it. A message that shows only on hover never reaches keyboard and touch users. Put it beside the field, where people already are.
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
- 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.
Rule of thumb: Show a message next to what it is about
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.Rule of thumb: Show a message next to what it is about
Fails
- InvalidAn “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.
Rule of thumb: Move to show a change, then stop
Verify the fix
5 checks, no mouse.
Test with: Keyboard, Screen reader, Zoom, Forced colors
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.
References
- WCAG Understanding: error-identification (opens in a new tab)
- WCAG Understanding: error-suggestion (opens in a new tab)
- WCAG Technique F81 (opens in a new tab)
- WCAG Technique G85 (opens in a new tab)
- WAI Tutorial: forms/notifications (opens in a new tab)
- w3.org: wai-aria-1.2 (opens in a new tab)
- developer.mozilla.org: aria-errormessage (opens in a new tab)
- developer.mozilla.org: setCustomValidity (opens in a new tab)
- design-system.service.gov.uk: error-message (opens in a new tab)
- webaim.org: up-and-coming-aria (opens in a new tab)
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.