Accessible forms: labels, errors and help that work for everyone

TL;DR

Difficulty: Intermediate

Most people who hit a broken form just leave: 69% of disabled online shoppers click away from a hard site, and only 8% tell the owner.

  • Give every field a visible label tied to it with for and id. A placeholder is not a label.
  • Group related choices in a fieldset with a legend, say required in words, and add autocomplete to fields about the person.
  • Connect hints and errors with aria describedby. Errors name the field and the fix, appear in a summary that gets focus, and never rely on colour.
  • Let people extend time limits, drop puzzle CAPTCHAs, do not ask twice for the same data, and allow paste and password managers at login.

A form is where a visitor stops reading and starts doing, and where most barriers on a website live. This chapter rebuilds an invented Brighton bookshop's newsletter and account sign up step by step, in HTML and then in Rails, so that a screen reader user, a keyboard user, someone zoomed to 200% and someone with dyslexia can all finish it.

Why people give up on forms

A form is where a visitor stops reading and starts doing. They sign up for the newsletter, open an account, ask a question, pay. It is also where most of the barriers on a website live, because a form asks the person to understand, decide and type, and every one of those steps can go wrong.

The people it goes wrong for rarely tell you. In the Click Away Pound survey of 2019, 69% of disabled online shoppers said they simply leave a website they find difficult to use, and only 8% of those who have trouble contact the site owner about it.1 So a broken form does not produce complaints. It produces silence, and a sign up count that looks a little low for reasons nobody can see.

The barriers themselves are not rare either. The WebAIM Million, an automated scan of the home pages of the top one million websites, found missing form input labels on 51% of them in its 2026 report. The average home page had 6.9 form inputs, and 33.1% of all the inputs it found had no proper label at all.2 That is one of the six error types that make up 96% of everything the scan detects, and it has been on that list for years.2

This chapter is about building a form that everyone can complete. I go through it one idea at a time, with the broken HTML and the fixed HTML next to each other, and I keep to forms. The keyboard and focus side gets its own chapter, the checkout gets its own chapter, and the standard itself is explained in WCAG 2.1 AA explained. If you have not read why a plugin cannot do this work for you, start with why accessibility overlays do not make your site compliant.

Example: four customers and one newsletter form

Brightwater Books is an invented independent bookshop in Brighton with an online shop at brightwaterbooks.example. Ruth owns it. Ade is the developer who looks after the site. On every page there is a newsletter box, and it looks like this in the code:

<div class="newsletter">
  <input type="text" placeholder="Your email">
  <div class="btn" onclick="subscribe()">Go</div>
</div>

It looks tidy on screen: a pale grey box with "Your email" in it and a pink "Go" next to it. Here is what four of Ruth's customers, all invented, experience.

  • Tom is blind and uses VoiceOver, the screen reader built into his iPhone. When he reaches the field, VoiceOver says "text field". Nothing tells him what it is for, because a placeholder is not a reliable name. He guesses. Then he cannot find a button at all, because the "Go" is a plain div, which a screen reader does not report as something you can press.
  • Margaret navigates with the keyboard since a stroke made a mouse hard to use. She can Tab into the field, but the Tab key skips the "Go" completely, because a div cannot receive keyboard focus. She has typed her email and has no way to send it.
  • Daniel has low vision and zooms his browser to 200%. The pale grey placeholder text is hard for him to read, and once he types, the hint disappears, so he cannot check what the field wanted.
  • Chloe has dyslexia. She types her email, presses Enter, nothing happens, and there is no message to say why.

Four people who wanted the newsletter, zero sign ups, zero complaints. The rest of this chapter fixes it.

A visible label, tied to its field

Every field needs a label: a short piece of visible text that says what goes in it. And the label has to be tied to the field in the code, not just placed next to it on the screen.

That second part is the one people miss. Three success criteria of WCAG 2.1 meet here.3 Criterion 1.3.1, info and relationships, says that a relationship you can see (this text belongs to that box) must also exist in the code. Criterion 3.3.2, labels or instructions, says that a field that needs input must have a label or instructions.4 Criterion 4.1.2, name, role, value, says every control must expose its name and its role to assistive technology. The name of a field is what a screen reader reads out, and for a form field it normally comes from its label.

In HTML you tie a label to a field with the for attribute on the label, which must match the id attribute on the input. A pleasant side effect: clicking or tapping the label puts the cursor in the field, which makes the target larger for anyone with a tremor or a small screen.

Example: the email field, broken and fixed

Before, the field has no label at all:

<input type="text" placeholder="Your email">

After, Ade adds a visible label and ties it to the field:

<label for="newsletter-email">Email address</label>
<input type="email" id="newsletter-email" name="email">

What each part does:

  • label is the visible text. Sighted users read it, and a screen reader reads it as the field's name.
  • for="newsletter-email" names the field this label belongs to. It must match the id exactly.
  • type="email" tells the browser this is an email address. Phones show a keyboard with the @ sign, and the browser can check the format.
  • id="newsletter-email" is the unique identifier the label points at. Every id on a page must be unique, so two newsletter boxes on one page need two different values.
  • name="email" is the key the server receives. It has nothing to do with accessibility, but the form does not work without it.

Now Tom hears "Email address, text field" when he reaches the box. Daniel sees "Email address" above the field in normal text, and it stays there while he types.

A placeholder is not a label

The placeholder is the grey text inside an empty field. It is tempting to use it as the label because it saves space. It fails for several reasons at once: it disappears as soon as the person starts typing, it is usually pale grey and hard to read, and it is not reliably read out as the field's name by every combination of browser and screen reader.

The HTML standard itself says so in plain words: "The placeholder attribute should not be used as an alternative to a label."5 Use a placeholder, if at all, for an example of the format, and keep the real label outside the field. Better still, put any example into visible hint text, which I come to below.

Example: the placeholder that vanishes

Ruth's account sign up form asks for a date of birth for the reader club discount, and the only instruction is a placeholder:

<input type="text" id="dob" placeholder="DD/MM/YYYY">

Chloe starts typing "4 Ma", stops to check the format, and the hint has gone. She deletes what she typed to see it again. Ade changes it to a label plus a hint that stays visible:

<label for="dob">Date of birth</label>
<p id="dob-hint">For example, 27 03 1985</p>
<input type="text" id="dob" name="dob" inputmode="numeric" aria-describedby="dob-hint">

The label says what the field is, the hint says how to fill it in and never disappears, and aria-describedby ties the hint to the field so a screen reader reads it after the label. The section on help text explains that attribute properly. inputmode="numeric" asks phones for the number keyboard.

Some questions are answered by a group of controls: a set of radio buttons, a set of checkboxes, or three boxes for day, month and year. Each control has its own label, but the question that ties them together needs a label too. Otherwise a screen reader user hears "Yes, radio button" and has no idea what they are saying yes to.

The HTML for this is the fieldset element, which wraps the group, and the legend element, which is the question. The W3C forms tutorial recommends exactly this for related controls such as radio buttons and checkboxes.6 Most screen readers then read the legend when the person enters the group, so the question and the answer arrive together. This is criterion 1.3.1 again: the visual grouping must exist in the code.3

Example: which newsletters would you like?

Brightwater Books sends three newsletters: new releases, author events, and children's books. The first version is three checkboxes under a bold line of text:

<p><strong>Which newsletters would you like?</strong></p>
<input type="checkbox" id="nl-new" name="lists" value="new">
<label for="nl-new">New releases</label>
<input type="checkbox" id="nl-events" name="lists" value="events">
<label for="nl-events">Author events</label>
<input type="checkbox" id="nl-kids" name="lists" value="kids">
<label for="nl-kids">Children's books</label>

Each box has a label, which is good. But the question is a paragraph that the screen reader may skip when Tom moves straight to the checkboxes, so he hears "Author events, checkbox, not checked" without the question. Ade wraps the group:

<fieldset>
  <legend>Which newsletters would you like?</legend>
  <input type="checkbox" id="nl-new" name="lists[]" value="new">
  <label for="nl-new">New releases</label>
  <input type="checkbox" id="nl-events" name="lists[]" value="events">
  <label for="nl-events">Author events</label>
  <input type="checkbox" id="nl-kids" name="lists[]" value="kids">
  <label for="nl-kids">Children's books</label>
</fieldset>

Now Tom hears the question when he enters the group, then each choice. The [] in name="lists[]" is a server detail: it tells Rails, among others, to collect several ticked values into a list.

Say which fields are required, in words

A red star next to a label is the usual way to mark a required field. On its own it has two problems. Some people do not know what the star means, and a star that is only red, or only a star, is not always read out in a helpful way.

Three things fix it. First, say at the top of the form what the convention is, or better, mark the optional fields instead when most fields are required. Second, put the word into the label. Third, add the required attribute to the field, which tells the browser and the screen reader that the field must be filled in. Screen readers announce it as "required". This sits under 3.3.2, which asks for labels or instructions where input is needed.4

Example: the sign up form says what it needs

Ruth's account form has four fields, and only the phone number is optional. Ade writes:

<p>All fields are required unless they say optional.</p>

<label for="first-name">First name</label>
<input type="text" id="first-name" name="first_name" required>

<label for="phone">Phone number (optional)</label>
<input type="tel" id="phone" name="phone">

One sentence explains the rule once, the one exception says "optional" in its own label, and required gives the browser and the screen reader the same information. There is no star, so there is nothing to explain.

Tell the browser what each field is for

Typing your own name, address and email again on every site is tiring for anyone. For someone with a motor impairment, a memory difficulty or dyslexia it can be the reason they stop. Browsers can fill these fields in automatically, but only if the form says what each field is.

That is criterion 1.3.5, identify input purpose, at Level AA: where a field asks for information about the user themselves, its purpose must be identifiable in the code.7 In HTML you do that with the autocomplete attribute and one of the fixed values defined in the HTML standard, such as name, given-name, family-name, email, tel, street-address, postal-code, new-password and current-password.8 The Understanding document for 1.3.5 lists the purposes and explains that they borrow from the HTML autofill values.7

Example: the account sign up form, filled in one tap

Before, the fields had labels but no purpose:

<label for="email">Email address</label>
<input type="email" id="email" name="email">
<label for="password">Password</label>
<input type="password" id="password" name="password">

After:

<label for="given">First name</label>
<input type="text" id="given" name="given_name" autocomplete="given-name" required>

<label for="family">Last name</label>
<input type="text" id="family" name="family_name" autocomplete="family-name" required>

<label for="email">Email address</label>
<input type="email" id="email" name="email" autocomplete="email" required>

<label for="password">Create a password</label>
<input type="password" id="password" name="password" autocomplete="new-password" required>

Margaret now selects her saved details once and the browser fills in her first name, last name and email. For the password, new-password tells her password manager to offer a strong new one and save it, so she never has to type or remember it. On the login form later, current-password lets the same manager fill it back in.

Help text that is read at the right moment

Some fields need more than a label: the rules for a password, the reason you ask for a phone number, the format of a date. That help must be visible, close to the field, and connected to it in the code, so that a screen reader user hears it when they arrive at the field and not three fields later.

The connection is the aria-describedby attribute. ARIA stands for Accessible Rich Internet Applications, a W3C specification of extra attributes that give assistive technology information HTML alone does not carry.9 aria-describedby takes the id of one or more other elements and makes their text the field's description. A screen reader reads the name (from the label) first and the description after it.

Example: the password rules

Ruth's shop platform requires passwords of at least 12 characters. The first version tells you only after you fail. Ade puts the rule in a hint and connects it:

<label for="password">Create a password</label>
<p id="password-hint">Use at least 12 characters. A short sentence works well.</p>
<input type="password" id="password" name="password"
       autocomplete="new-password" required aria-describedby="password-hint">

Tom hears: "Create a password, secure text field, required. Use at least 12 characters. A short sentence works well." Daniel, zoomed in, sees the hint directly under the label, so it stays in view next to the field. Chloe gets the rule before she types, not after she gets it wrong.

Errors that say what went wrong and how to fix it

Mistakes happen in every form. What matters is what the form does next. WCAG has two criteria for it. Criterion 3.3.1, error identification, at Level A: if an error is detected automatically, the field in error is identified and the error is described to the user in text.10 Criterion 3.3.3, error suggestion, at Level AA: if the form knows how to fix it, it tells the person, unless that would put security at risk.11

In words that means three things. Name the field. Say what is wrong in plain language. Say what to do instead. The GOV.UK Design System, which the UK government built and tested for its own services, is a very good model for the wording and the markup, and I lean on it below.1213

Example: from "Invalid input" to a message that helps

Ruth's old form showed one line at the top after a failed submit: "Invalid input." Ade rewrites each message so it names the problem and the fix:

FieldBeforeAfter
Email addressInvalid inputEnter an email address in the correct format, like name@example.com
First nameRequiredEnter your first name
PasswordPassword does not meet requirementsYour password must be at least 12 characters
Date of birthInvalid dateDate of birth must include a year

Every new message starts from what the person should do, uses the field's own name, and is short. None of them blames anyone. The format follows the GOV.UK guidance on error messages.13

Errors that a screen reader actually hears

A good message is useless if nobody hears it. A red message under a field is visible to sighted users, but a screen reader user who pressed "Sign up" may hear the page reload and nothing else. Three techniques, used together, close that gap.

First, an error summary at the top of the form. The GOV.UK pattern is a box with the heading "There is a problem" and a list of every error, each one a link to the field it belongs to. When the page shows errors, keyboard focus moves to that summary, so a screen reader reads it straight away.12 The GOV.UK validation guidance also adds "Error: " to the start of the page title, so a screen reader announces the problem as soon as the page loads.12

Second, the message next to each field, connected with aria-describedby, and with a visually hidden "Error:" in front so a screen reader user knows this text is an error and not a hint. GOV.UK writes it this way in its error message component.13

Third, aria-invalid="true" on each field in error. The WAI ARIA specification defines it as the state that tells assistive technology a value does not match what the application expects, and screen readers read it as "invalid".9

Tap or click to open full screen and move around

Example: the sign up form after a failed submit

Tom submits Ruth's account form with a typo in his email and no first name. The server sends the page back with this markup:

<title>Error: Create your account, Brightwater Books</title>
...
<div class="error-summary" role="alert" tabindex="-1">
  <h2>There is a problem</h2>
  <ul>
    <li><a href="#given">Enter your first name</a></li>
    <li><a href="#email">Enter an email address in the correct format, like name@example.com</a></li>
  </ul>
</div>

<label for="given">First name</label>
<p id="given-error" class="error-message">
  <span class="visually-hidden">Error:</span> Enter your first name
</p>
<input type="text" id="given" name="given_name" autocomplete="given-name"
       required aria-invalid="true" aria-describedby="given-error">

<label for="email">Email address</label>
<p id="email-error" class="error-message">
  <span class="visually-hidden">Error:</span> Enter an email address in the correct format, like name@example.com
</p>
<input type="email" id="email" name="email" autocomplete="email"
       value="tom@brightwater" required aria-invalid="true" aria-describedby="email-error">

Step by step, this is what Tom hears and does:

  1. The page loads. VoiceOver reads the title, which begins "Error".
  2. A few lines of JavaScript move focus to the error summary (that is why it has tabindex="-1", which lets a script focus it without adding it to the Tab order). VoiceOver reads "There is a problem" and the two errors. role="alert" makes sure it is announced even if focus handling fails.
  3. Tom activates the first link. Focus jumps to the first name field. He hears "First name, text field, invalid, required. Error: Enter your first name."
  4. He types his name and moves to the email field, which still holds what he typed, "tom@brightwater". The form kept his answer, so he only adds ".example" rather than starting again.
  5. He submits. No errors, and the confirmation page title is "Account created, Brightwater Books", which VoiceOver reads on load.

The visually-hidden class is a common CSS pattern that hides text from the screen but leaves it for screen readers. Ade uses the version that clips the element to one pixel rather than display: none, because display: none hides text from screen readers too.

Never use colour alone

A red border is a fine signal for many people, but not for everyone. Someone with a colour vision deficiency may not see the difference, and a screen reader does not report border colours at all. Criterion 1.4.1, use of colour, at Level A, says colour must not be the only visual means of conveying information or distinguishing an element.14

So an error state needs something besides the colour: the text message, and ideally an icon or a thicker border as well. The same goes for "the fields in green are done" or a link that is only distinguished by its colour.

Example: the red border that said nothing

Ruth's first version marked an invalid email only by turning its border red. Daniel, zoomed to 200%, had the field filling his screen and could not see the summary at the top, and for him the red was faint. After Ade's change, an error field has a thicker border, the message in text directly above the field, and the word "Error:" at the start of the message for screen readers. Each of the three would be enough for some people. Together they reach everyone.

Time limits that people can extend

Some forms quietly time out. A session expires after 15 minutes, and everything typed is lost. For someone who types slowly, reads with a screen reader, or needs a break, 15 minutes can be too short.

Criterion 2.2.1, timing adjustable, at Level A, asks that for each time limit the user can turn it off, adjust it to at least ten times the default, or be warned before it runs out and given at least 20 seconds to extend it with a simple action, at least ten times. There are exceptions, for example for real time events such as an auction and for limits longer than 20 hours.15

Example: the sign up form that forgot everything

Brightwater Books' platform ends an idle session after 15 minutes. Margaret, who uses an on screen keyboard on bad days, filled in the account form, came back from making a cup of tea, pressed "Create account" and landed on an empty form. Ade makes two changes. The sign up page does not need a logged in session at all, so he takes it out of the time limit entirely. For pages that do need one, two minutes before the end a dialog appears saying "You will be signed out in 2 minutes. Do you want more time?" with a "Stay signed in" button that receives focus. Pressing it resets the timer, and it can be pressed as often as needed. That meets the "extend" option of 2.2.1, with far more than 20 seconds to respond.

CAPTCHAs, and better ways to stop bots

A CAPTCHA is the test that asks you to prove you are human: type the distorted letters, pick every picture with a bus. Every interactive version of it locks out somebody. A W3C note on the inaccessibility of CAPTCHA, maintained by the Accessible Platform Architectures Working Group, puts it bluntly: the very nature of the interactive task "inherently excludes many people with disabilities, resulting in a denial of service to these users", and research suggests many popular CAPTCHA techniques are no longer particularly effective or secure either.16 The note is a Group Draft Note, so it is guidance, not a standard, but it is the best overview there is.

The same note lists approaches that ask the person to do nothing at all: spam filtering, heuristics that look at how the form was submitted, and honeypots, which are fields a human never sees but a simple bot fills in.16 For a small shop's newsletter or contact form, a combination of these usually stops the junk without stopping a single customer.

Example: replacing the bus pictures

Brightwater Books added an image CAPTCHA to the newsletter box after a wave of junk sign ups. Tom could not solve it, and the audio option was hard to follow. Ade removes it and adds three checks that no customer notices:

<div class="hp" aria-hidden="true">
  <label for="website">Leave this empty</label>
  <input type="text" id="website" name="website" tabindex="-1" autocomplete="off">
</div>
  • The honeypot field is hidden with CSS, and also hidden from screen readers with aria-hidden="true" and removed from the Tab order with tabindex="-1", so Tom and Margaret never reach it. Bots that fill every field fill this one, and the server quietly drops those submissions.
  • The server rejects forms submitted faster than a person could type them, a few seconds after the page loaded.
  • Every new subscriber gets a confirmation email with a link, a double opt in, so a fake address never receives the newsletter.

The junk sign ups stop, and nobody has to prove anything.

Two newer rules from WCAG 2.2

WCAG 2.2, published as a W3C Recommendation in October 2023 and updated since, adds criteria that matter for forms.17 The law in Europe still points at WCAG 2.1 AA, but these two take little effort to meet and remove real frustration, so they are worth meeting now.

Criterion 3.3.7, redundant entry, at Level A: information a person has already entered, or been given, in the same process must be filled in for them or be available to select, unless entering it again is essential, needed for security, or no longer valid.18 The Understanding document notes that some people with cognitive disabilities find it hard to remember what they entered before.18

Criterion 3.3.8, accessible authentication (minimum), at Level AA: no step of a login may rely on a cognitive function test, such as remembering a password or solving a puzzle, unless there is an alternative or a mechanism that helps. The Understanding document names supporting password managers and allowing copy and paste as examples of such a mechanism.19

Example: the second address and the login code

Ruth's checkout asks for a delivery address and then a billing address. Most customers give the same one twice. Ade adds a checkbox, "Billing address is the same as delivery address", ticked by default, and the billing fields appear only when it is unticked. That meets 3.3.7, and it is quicker for everyone.

On the login form, the shop sends a six digit code by email for new devices. The old code field blocked pasting "for security". Ade removes that block, adds autocomplete="one-time-code" so phones can offer the code from the message, and keeps autocomplete="current-password" on the password field so a password manager can fill it. Chloe no longer has to read six digits from one screen and type them on another. That meets 3.3.8.

What the law expects of your forms

In the UK, the Equality Act 2010 places a duty to make reasonable adjustments on anyone providing a service to the public, and a website is part of the service.2021 The Act does not name a technical standard, but WCAG 2.1 AA is the benchmark everyone measures against, and a sign up form that a blind customer cannot complete is hard to defend as reasonable. If you sell to consumers in the European Union, the European Accessibility Act applies to that business as well, and the harmonised standard under it, EN 301 549, builds on WCAG 2.1 AA for web content.2223 Who exactly must comply, from when and with which exemptions, is covered in my article on accessibility law for online businesses. The point here is narrower: the duty sits with the business that runs the form. No platform and no plugin takes it off you.

The whole sign up form, rebuilt

Here is the account sign up form for Brightwater Books from start to finish, with every idea above in place. It is the version Ade ships.

Example: the finished form in HTML

<form action="/account" method="post" novalidate>
  <h1>Create your account</h1>
  <p>All fields are required unless they say optional.</p>

  <label for="given">First name</label>
  <input type="text" id="given" name="given_name" autocomplete="given-name" required>

  <label for="family">Last name</label>
  <input type="text" id="family" name="family_name" autocomplete="family-name" required>

  <label for="email">Email address</label>
  <p id="email-hint">We send your order confirmations here.</p>
  <input type="email" id="email" name="email" autocomplete="email"
         required aria-describedby="email-hint">

  <label for="password">Create a password</label>
  <p id="password-hint">Use at least 12 characters. A short sentence works well.</p>
  <input type="password" id="password" name="password" autocomplete="new-password"
         required aria-describedby="password-hint">

  <fieldset>
    <legend>Which newsletters would you like? (optional)</legend>
    <input type="checkbox" id="nl-new" name="lists[]" value="new">
    <label for="nl-new">New releases</label>
    <input type="checkbox" id="nl-events" name="lists[]" value="events">
    <label for="nl-events">Author events</label>
    <input type="checkbox" id="nl-kids" name="lists[]" value="kids">
    <label for="nl-kids">Children's books</label>
  </fieldset>

  <button type="submit">Create account</button>
</form>

Walking through the decisions in order:

  1. novalidate switches off the browser's own error bubbles, because they look different in every browser and disappear quickly. The server checks everything and returns the error summary and messages shown earlier. The required and type attributes stay, because screen readers still announce them.
  2. One sentence explains which fields are required.
  3. Every field has a visible label tied with for and id.
  4. Every field about the person has an autocomplete value.
  5. Hints are visible and connected with aria-describedby. When an error appears, its message id is added to the same attribute, so the field is described by both.
  6. The newsletter choices are grouped in a fieldset with a legend.
  7. The submit control is a real button with a label that says what happens. A button can be reached with Tab and pressed with Enter or Space, which the old div could not.

Margaret can complete it by keyboard alone, Tom by screen reader, Daniel at 200% zoom with everything in a single column, and Chloe with her browser filling most of it in for her.

The same form in Rails

Ruth's shop runs on Ruby on Rails, so Ade builds the form with Rails' form helpers rather than raw HTML. The form_with helper builds a form for a model, form.label writes a label with the right for, and form.email_field writes an input with the matching id.24

Rails has one default worth knowing about. When a model has errors, Rails wraps each affected field and label in a div with the class field_with_errors, controlled by the setting config.action_view.field_error_proc.25 That wrapper gives you something to style, but it adds nothing a screen reader announces, so the message, aria-invalid and aria-describedby still have to come from you.

Example: the email field as a Rails view

<%= form_with model: @customer, url: account_path do |form| %>
  <% if @customer.errors.any? %>
    <div class="error-summary" role="alert" tabindex="-1" data-error-summary>
      <h2>There is a problem</h2>
      <ul>
        <% @customer.errors.each do |error| %>
          <li><%= link_to error.full_message, "#customer_#{error.attribute}" %></li>
        <% end %>
      </ul>
    </div>
  <% end %>

  <% email_error = @customer.errors[:email].first %>
  <%= form.label :email, "Email address" %>
  <p id="email-hint">We send your order confirmations here.</p>
  <% if email_error %>
    <p id="email-error" class="error-message">
      <span class="visually-hidden">Error:</span> <%= email_error %>
    </p>
  <% end %>
  <%= form.email_field :email,
        autocomplete: "email",
        required: true,
        aria: { invalid: email_error.present?,
                describedby: ["email-hint", ("email-error" if email_error)].compact.join(" ") } %>

  <%= form.button "Create account", type: "submit" %>
<% end %>

Line by line:

  • form_with model: @customer builds the form for a customer record. Rails gives the email field the id customer_email, and the summary links point at those ids.
  • The summary only renders when there are errors. data-error-summary is the hook for a few lines of JavaScript that focus it on page load.
  • form.label :email, "Email address" writes <label for="customer_email">Email address</label>.
  • email_error holds the message for this field, if any. In the model, Ade writes each validation message in the helpful style shown earlier, for example "Enter an email address in the correct format, like name@example.com", so the summary and the field say the same thing, which GOV.UK also recommends.12
  • The aria: hash becomes aria-invalid and aria-describedby attributes. When there is no error, aria-describedby only points at the hint. When there is one, it points at both.
  • form.button writes a real button element.

Ade also sets field_error_proc to return the field unchanged, because the div wrapper broke the layout of the label and field, and the error styling now comes from aria-invalid in the CSS.

A short checklist for every form

When Ade reviews any form on Ruth's site now, he runs through this list. It is the chapter in seven lines:

  • Every field has a visible label tied to it with for and id. No placeholder doing a label's job.
  • Related choices sit in a fieldset with a legend.
  • Required and optional are said in words, and required is set.
  • Fields about the person have an autocomplete value.
  • Hints are visible and connected with aria-describedby.
  • Errors name the field and the fix, appear in a summary that gets focus and next to the field, and do not rely on colour.
  • No time limit without a way to extend it, no puzzle CAPTCHA, no second entry of the same data, and paste and password managers allowed at login.

Then he tests it: by keyboard alone, with a screen reader, and at 200% zoom. Testing gets its own chapter in this series.

Conclusion

People give up on forms because the form gave up on them first: a box with no name, a hint that vanished, an error nobody announced, a puzzle they could not solve. Almost none of them will tell you. The fixes are ordinary HTML, a handful of attributes and a habit of writing messages that help, and they make the form quicker for every customer, not only for the four in this chapter.

I build forms this way from the first line, as part of building to WCAG 2.1 AA: labels tied to every field, errors named in text and reachable, automated checks on every build, and keyboard and screen reader passes by hand on the key journeys. That is not a badge and not a guarantee. It is how a form works for everyone, and it is a duty that stays with whoever runs the site.

If you want to know whether every customer can actually finish your sign up, contact and checkout forms, book the free workshop: we go through your forms together, and the first two weeks of work are on me.

Sources

  1. 1.

    Freeney Williams and Click Away Surveys (Rick Williams and Steve Brownlow), Press release: Click Away Pound 2019, UK retailers lose out on £17 billion by ignoring needs of disabled shoppers online, 6 February 2020, https://www.clickawaypound.com/downloads/CAP2019PR2.pdf

  2. 2.

    WebAIM, The WebAIM Million: an annual accessibility analysis of the top 1,000,000 home pages, 2026 report, Utah State University, updated 30 March 2026, https://webaim.org/projects/million/

  3. 3.

    W3C, Web Content Accessibility Guidelines (WCAG) 2.1, W3C Recommendation, 5 June 2018, current edition 6 May 2025, success criteria 1.3.1, 3.3.2 and 4.1.2, https://www.w3.org/TR/WCAG21/

  4. 4.

    W3C Web Accessibility Initiative, Understanding Success Criterion 3.3.2: Labels or Instructions, https://www.w3.org/WAI/WCAG21/Understanding/labels-or-instructions.html

  5. 5.

    WHATWG, HTML Living Standard, The input element, the placeholder attribute, https://html.spec.whatwg.org/multipage/input.html

  6. 6.

    W3C Web Accessibility Initiative, Forms Tutorial: Grouping Controls, https://www.w3.org/WAI/tutorials/forms/grouping/

  7. 7.

    W3C Web Accessibility Initiative, Understanding Success Criterion 1.3.5: Identify Input Purpose, https://www.w3.org/WAI/WCAG21/Understanding/identify-input-purpose.html

  8. 8.
  9. 9.

    W3C, Accessible Rich Internet Applications (WAI ARIA) 1.2, W3C Recommendation, 6 June 2023, states and properties aria-describedby and aria-invalid, https://www.w3.org/TR/wai-aria-1.2/

  10. 10.

    W3C Web Accessibility Initiative, Understanding Success Criterion 3.3.1: Error Identification, https://www.w3.org/WAI/WCAG21/Understanding/error-identification.html

  11. 11.

    W3C Web Accessibility Initiative, Understanding Success Criterion 3.3.3: Error Suggestion, https://www.w3.org/WAI/WCAG21/Understanding/error-suggestion.html

  12. 12.

    Government Digital Service, GOV.UK Design System, Error summary component (move focus to the summary, the heading "There is a problem", link to each answer, add "Error: " to the page title), https://design-system.service.gov.uk/components/error-summary/

  13. 13.

    Government Digital Service, GOV.UK Design System, Error message component (hidden "Error:" prefix, aria-describedby, how to write error messages), https://design-system.service.gov.uk/components/error-message/

  14. 14.

    W3C Web Accessibility Initiative, Understanding Success Criterion 1.4.1: Use of Color, https://www.w3.org/WAI/WCAG21/Understanding/use-of-color.html

  15. 15.

    W3C Web Accessibility Initiative, Understanding Success Criterion 2.2.1: Timing Adjustable, https://www.w3.org/WAI/WCAG21/Understanding/timing-adjustable.html

  16. 16.

    W3C Accessible Platform Architectures Working Group (Scott Hollier, Janina Sajka, Jason White, Michael Cooper), Inaccessibility of CAPTCHA: Alternatives to Visual Turing Tests on the Web, W3C Group Draft Note, 16 December 2021, https://www.w3.org/TR/turingtest/

  17. 17.

    W3C, Web Content Accessibility Guidelines (WCAG) 2.2, W3C Recommendation, 5 October 2023, current edition 12 December 2024, https://www.w3.org/TR/WCAG22/

  18. 18.

    W3C Web Accessibility Initiative, Understanding Success Criterion 3.3.7: Redundant Entry, https://www.w3.org/WAI/WCAG22/Understanding/redundant-entry.html

  19. 19.

    W3C Web Accessibility Initiative, Understanding Success Criterion 3.3.8: Accessible Authentication (Minimum), https://www.w3.org/WAI/WCAG22/Understanding/accessible-authentication-minimum.html

  20. 20.

    UK Parliament, Equality Act 2010, section 20, Duty to make adjustments, legislation.gov.uk, https://www.legislation.gov.uk/ukpga/2010/15/section/20

  21. 21.

    UK Parliament, Equality Act 2010, section 29, Provision of services, etc., legislation.gov.uk, https://www.legislation.gov.uk/ukpga/2010/15/section/29

  22. 22.

    European Parliament and Council, Directive (EU) 2019/882 of 17 April 2019 on the accessibility requirements for products and services (European Accessibility Act), EUR Lex, 2019, https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32019L0882

  23. 23.

    CEN, CENELEC and ETSI, EN 301 549 V3.2.1 (2021 03), Accessibility requirements for ICT products and services, clause 9, ETSI, 2021, https://www.etsi.org/deliver/etsi_en/301500_301599/301549/03.02.01_60/en_301549v030201p.pdf

  24. 24.

    Ruby on Rails Guides, Action View Form Helpers, https://guides.rubyonrails.org/form_helpers.html

  25. 25.

    Ruby on Rails Guides, Configuring Rails Applications, section Configuring Action View, config.action_view.field_error_proc, https://guides.rubyonrails.org/configuring.html