Sub topic 14
Testing a form with keyboard, screen reader, and users
This chapter assumes you can build a form with labels, fieldsets, hint text, and the validation code from earlier chapters. It covers three ways to test that form. Each one catches problems the others miss.
Why test in three ways
Automated checks find missing labels and low contrast. They cannot tell you whether an error message makes sense or whether the focus order matches the visual order. A form needs a keyboard pass, a screen reader pass, and a session with real users.
| Method | What it finds | What it misses |
|---|---|---|
| Keyboard only | Focus order, traps, invisible focus, unreachable controls | Spoken names and error announcements |
| Screen reader | Missing or wrong labels, unannounced errors, lost group questions | Confusing wording that is read correctly |
| Real users | Unclear questions, wrong field order, abandoned steps | Rare technical failures |
Test with the keyboard
Put the mouse aside and use only these keys:
- Tab and Shift+Tab move between controls.
- Space toggles checkboxes and presses buttons.
- Arrow keys move between radio buttons in one group.
- Enter submits the form.
Work through the form and check each item:
- Every control can be reached, and the tab order matches the visual order.
- A visible focus indicator shows where you are at every step.
- Clicking a label is not required for any task, and pressing Tab never gets stuck.
- A radio group is one Tab stop, and arrow keys change the choice.
- Submit the form with errors. Focus should move to the first invalid field, or to an error summary.
- After you fix an error and submit again, the form should not lose your other answers.
If a control is skipped, the cause is often a div used as a button or a positive tabindex value. Replace the div with a real button and remove positive tabindex values.
Test with a screen reader
A screen reader reads the page aloud and lets users move through it by keyboard. Try NVDA on Windows with Firefox or Chrome, VoiceOver on macOS or iOS with Safari, or TalkBack on Android. You don't need to be expert. Listen for what is announced as you Tab through each control.
Check these points:
- Each field announces its label and type, for example "Email address, edit text, required".
- Hint text is read after the label, because of
aria-describedby. - Each radio button announces the group question from the
legend, then its own label. - An invalid field announces "invalid" and its error message.
- After a failed submit, the reader announces where focus landed, so the user hears the summary or the first error.
- Errors that appear on blur are not silent. If you show one without moving focus, confirm it is announced or that it is reachable from the field.
Compare what you hear with what you see. If a sighted user can read "Postcode, for example SW1A 1AA" and the reader says only "edit text", the association is missing.
Test with real users
Recruit five or so people who match your audience, including some who use assistive technology. Give each a task, not instructions, such as "Sign up for the newsletter." Then watch without helping.
- Note where they hesitate, re-read, or backtrack.
- Ask them to say what they think each field wants.
- Trigger an error on purpose and see whether they can fix it alone.
- Record fields that people leave blank or abandon on.
Fix the problems you see most often, then test again.
A quick automated check
Automated tools catch the cheap mistakes first. This script lists inputs that have no accessible label. Run it in the browser console.
const unlabeled = [...document.querySelectorAll('input, select, textarea')]
.filter((el) => el.type !== 'hidden' && el.type !== 'submit')
.filter((el) => el.labels.length === 0 &&
!el.hasAttribute('aria-label') &&
!el.hasAttribute('aria-labelledby'));
console.log(unlabeled.length + ' control(s) without a label', unlabeled);An empty list does not prove the form is accessible. It only shows that every control has some name.
Exercise
You submit a form with an empty required field. A mouse user sees a red message, but a screen reader user hears nothing and stays at the submit button. Which two fixes would you test for, and in which pass would you notice the problem?
Show answer
Move focus to the first invalid field (or to an error summary), and link the message to the field with aria-describedby with aria-invalid set. You would notice the problem in the screen reader pass, and the keyboard pass would also show that focus did not move.
Exercise
Why is a clean result from an automated label checker not enough to call a form tested?
Show answer
It only confirms that controls have names. It cannot judge whether the names make sense, whether focus order is logical, whether errors are announced, or whether users understand the questions.