Sub topic 14
Testing a form with keyboard, screen reader, and users
This chapter assumes you can build a form with labels, groups, and error messages, and that you have read the earlier chapters on labels, validation timing, and accessible errors. Here you check that the form works. Automated checks catch some problems. Keyboard, screen reader, and user testing catch the rest.
Why test in layers
No single test finds every form problem. Each method sees something the others miss.
| Method | Finds | Misses |
|---|---|---|
| Automated checks | Missing labels, bad `for`/`id` links, duplicate ids, low contrast | Whether a label or error message makes sense |
| Keyboard pass | Unreachable controls, bad tab order, lost focus, traps | Wording and screen reader output |
| Screen reader pass | Missing names, groups, and error announcements | Whether the form is easy to understand |
| Testing with users | Confusing questions, wrong field order, unclear errors | Rare setups you did not recruit for |
Run them in this order. Cheap checks first clear away the obvious faults, so later sessions spend time on harder problems.
Automated checks
Tools such as axe DevTools, Lighthouse, and WAVE scan a page for rule violations. For forms they reliably flag:
- Inputs with no accessible name.
- A
forattribute that points to an id that does not exist. - Duplicate ids, which break
aria-describedbyandforlinks. - Text and error colors with too little contrast.
- Missing
autocompletevalues on fields that collect personal data.
A clean report does not mean the form is accessible. A tool can confirm that a label exists. It cannot tell you that the label reads "Field 1". Treat automated checks as a first filter.
You can also write a small check of your own. This script lists every control that has no accessible name from a label or ARIA attribute. Paste it into the browser console on the page you are testing.
const controls = document.querySelectorAll('input, select, textarea');
const unnamed = [];
controls.forEach((control) => {
if (['hidden', 'submit', 'button', 'reset', 'image'].includes(control.type)) return;
const hasLabel = control.labels && control.labels.length > 0;
const hasAria =
control.hasAttribute('aria-label') || control.hasAttribute('aria-labelledby');
if (!hasLabel && !hasAria) {
unnamed.push(control);
}
});
console.log(unnamed.length + ' control(s) without a name', unnamed);The labels property is filled in by the browser from <label for> links and wrapping labels. If it is empty, the association is broken.
The keyboard pass
Put the mouse away. Load the form and complete it using only the keyboard. You need only a few keys:
TabandShift+Tabmove between controls.Spacetoggles checkboxes and presses buttons.- Arrow keys change the choice within a radio group.
Entersubmits the form from a text field.- Arrow keys or typing change the value of a select.
Work through this checklist.
- Reach. Every control, link, and button can be reached with
Tab. - Order. Focus moves in the same order as the visual layout. If it jumps around, the DOM order does not match the design, often because of CSS positioning or
tabindexvalues above zero. - Visibility. You can always see where focus is. A focus ring that was removed with
outline: noneand not replaced is a failure. - Operation. You can select every radio option, tick every checkbox, and open every select.
- No traps. Focus never gets stuck in a widget, such as a date picker, that you cannot leave.
- Submit. Pressing
Enterin a text field submits the form, and the button works withEnterandSpace. - Error recovery. Submit an invalid form. Focus should move to the first invalid field or to an error summary. Then fix the error and confirm you can continue from that spot without tabbing through the whole page again.
Common keyboard failures
- A custom-styled checkbox built from a
divthat cannot receive focus. Use a real<input type="checkbox">and style it. - A visually hidden input hidden with
display: none. This removes it from the tab order. Use a visually hidden technique that keeps it focusable. - Focus staying on the submit button after a failed submit, so keyboard users never learn that anything went wrong.
- A positive
tabindexsuch astabindex="3". It overrides natural order and is almost never correct.
The screen reader pass
A screen reader reads the page aloud or sends it to a braille display. You do not need to be an expert to find real problems. Pick one combination and learn its basic commands:
- NVDA or JAWS with Firefox or Chrome on Windows.
- VoiceOver with Safari on macOS and iOS.
- TalkBack with Chrome on Android.
Turn on the screen reader and move through the form with Tab. Listen for each control and check what is announced.
| What to check | What you should hear |
|---|---|
| Text field | The label, the field type, and any hint, such as "Postcode, edit text, For example, SW1A 1AA" |
| Required field | That it is required, from the `required` attribute |
| Radio button | The group question from the legend, the option label, and its position, such as "Preferred contact method, group, Email, radio button, 1 of 2" |
| Invalid field | The label, "invalid entry" or similar, and the error text |
| Submit failure | The error summary or the first error, announced when focus moves |
Exact wording varies between screen readers, and that is fine. Your job is to confirm that the same information is present: name, role, state, and description.
Also test reading mode. Use the screen reader's commands to jump by form control, by heading, and by landmark. A form with a clear h1, grouped fields, and an error summary headed "There is a problem" is much faster to navigate than a flat list of inputs.
Testing error announcements
Dynamic errors are the most fragile part. Check each of these:
- Leave a required field empty and tab away. If you validate on blur, is the message announced, or does the screen reader stay silent? Inline messages linked by
aria-describedbyare read when the user returns to the field, not when they appear. If you need immediate announcement, the message container needs a live region, such asrole="alert", and you should use that sparingly. - Submit with several errors. Focus should land on the error summary, and the summary's links should move focus to each field.
- Correct a field. The error should disappear, and
aria-invalidand thearia-describedbylink should be removed, as in the validation script from the earlier chapter.
Testing with users
Technical checks confirm that the form is operable. Only users can tell you whether it makes sense. A small test with five or so people finds most of the repeated problems.
Plan the session
- Pick realistic tasks. Ask someone to "sign up for the newsletter" or "change your delivery address". Do not say "fill in the form".
- Recruit people like your users. Include people who use assistive technology, people on phones, and people who are not confident with technology.
- Use realistic data. Give participants a card with a name, address, and so on, or let them use their own details if privacy allows. Test data that is too neat hides problems with long names, apostrophes, and unusual addresses.
- Ask them to think aloud, and stay quiet. Do not explain a confusing label. Note it.
- Include errors. Provide a task that is likely to trigger a validation error, such as a phone number in an unexpected format. How people recover is what you want to see.
What to watch for
- Hesitation before a field, which suggests an unclear label or hint.
- Pausing to read the same message twice.
- Leaving a field blank because it was unclear whether it was required.
- Retyping a whole entry after an error, which means input was not preserved or the message did not say what to change.
- Abandoning the form at a particular field.
- Using the wrong format, which means the hint was missing or placed where it was not seen.
Record what happened, not what people said they would do. A person may call a form "easy" and still make three errors on it.
Measure what you can
Even a small test can give numbers you can compare across versions.
| Measure | How to collect it |
|---|---|
| Completion rate | How many participants finished the task unaided |
| Time on task | Seconds from first field to confirmation |
| Errors per participant | Count of validation errors triggered |
| Recovery rate | How many fixed an error on the first attempt after seeing the message |
With live traffic, add analytics for field-level drop-off and error counts per field. A field that triggers many errors usually has a problem in its label, hint, or format rules, and you should fix that rather than only reword the message.
Record and retest
Keep a short log of each problem with the page, the method that found it, the steps to repeat it, and the fix. After fixing, run the same checks again. A change to one error message can break an aria-describedby link, so retest the keyboard and screen reader paths and not only the item you changed. Where you can, add the automated checks to your build process so regressions are caught early.
Exercise
A form passes an automated accessibility scan with no errors. During a keyboard pass, you submit it empty and focus stays on the submit button, with errors shown in red above the fields. Name two problems this reveals and say how to fix them.
Show answer
First, a scan cannot judge focus behavior, so passing it does not show the form is usable. Second, focus stays on the button, so keyboard and screen reader users get no signal that errors exist. Fix this by preventing submission when the form is invalid, then moving focus to an error summary placed at the top of the form, or to the first invalid field. Give the summary links to each field, and give each invalid field aria-invalid="true" and an aria-describedby link to its message. The red color alone is also not enough, so each message should include text such as "Error:" and say how to fix the problem.
Exercise
You run a user test with five people. Four of them leave the "Phone number" field blank and say afterward that they thought it was optional. The field is required. Which testing finding is this, and what two changes could you make?
Show answer
It is a marking problem that only user testing exposed, since the markup was valid and automated checks would pass. Change one: state clearly which fields are required, for example by adding "(optional)" to the optional fields or a note at the top explaining the convention, and make the marking consistent across the form. Change two: reconsider whether the phone number is needed at all. If it is not essential, remove it or make it optional, which also reduces the field count. Then retest with new participants.