Verify error identification
Description
This rule flags form input elements (input, select, textarea, or elements with role="textbox") for manual verification of WCAG Success Criterion 3.3.1 (Error Identification). The rule does not automatically detect whether an error message exists or is correctly implemented. Instead, it identifies potential error-prone fields and requires a human tester to verify that when an input error is automatically detected, the specific item in error is identified and the error is described to the user in text.
Automated tools cannot reliably determine:
- Whether an error condition exists at the time of testing
- Whether the error description is accurate and understandable
- Whether the association between the error message and the invalid field is programmatically correct
- Whether the timing of error detection (on
submit, onblur, or real-time) meets user needs
Therefore, this rule serves as a checkpoint for human evaluation.
Disabilities impacted
- Visual impairments: users with blindness or low vision who rely on screen readers need explicit text descriptions of errors. A red border around a field or an icon alone is not conveyed by screen readers. Without associated text, these users may never know an error occurred or which field is affected.
- Cognitive disabilities: users with cognitive or learning disabilities benefit from clear, plain-language error descriptions that explain what went wrong and how to fix it. Vague indicators (e.g.,
There was a problem
) without field-specific details can be confusing and frustrating. - Color blindness: users who cannot distinguish color cues (such as red error highlighting) rely on text-based identification to recognize which fields contain errors. Without text, error indicators that depend solely on color are invisible to them.
- Motor impairments: users who navigate via keyboard or voice commands require programmatically linked error messages so they can quickly jump to the field in error without excessive tabbing or searching.
Why it matters
Forms are fundamental to web interaction-login, registration, checkout, search, data entry, and countless other tasks. When a user submits a form with errors (e.g., missing required field, invalid email format, mismatched password), failing to clearly identify the error and describe it creates significant barriers. Without proper error identification, users may:
- Abandon the form entirely due to frustration or confusion
- Submit incorrect or incomplete data repeatedly
- Be unable to complete critical tasks (e.g., making a purchase, applying for a service)
- Spend excessive time hunting for which field caused the problem
WCAG Success Criteria 3.3.1 is a Level A requirement, meaning it is the most fundamental level of accessibility. Meeting this criterion is essential for any form to be considered accessible and is often a primary focus during accessibility audits.
What to manually verify
When this rule flags a form field, a human tester must verify the following:
- Error detection exists: when the user submits a form (or triggers validation via blur/real-time), does the system automatically detect input errors?
- The specific item in error is identified: Is it clear which field(s) contain the error? This can be achieved through:
- Inline error messages adjacent to the invalid field
- An error summary at the top of the form that links to or describes the specific fields
- Programmatic association using
aria-describedbyoraria-errormessage
- The error is described in text: is there a text-based description of the error (e.g.,
Email address is required
,Password must be at least 8 characters
) rather than only an icon or color change? - The error description is helpful: does the text explain what went wrong and, where appropriate, how to fix it (e.g.,
Enter a valid email address like name@example.com
)?
Manual test procedure
- Navigate to the form containing the flagged input elements.
- Submit the form with invalid data (e.g., empty required fields, malformed email, mismatched passwords).
- Observe whether error messages appear and whether they clearly identify each invalid field.
- Using a screen reader (NVDA, JAWS, or VoiceOver), verify that the error message is announced when the invalid field receives focus.
- Verify that the error message is available in text form (not solely conveyed by color, shape, or icon).
- If real-time validation is implemented (on blur or as the user types), repeat steps 2-5 for those triggers.
Coding problems and solutions
Common coding problems
- No error message at all: the form submission fails silently or only changes visual styling without any text announcing the error.
- Generic error message only: a message like
Please fix errors
appears at the top of the page, but the specific fields in error are not identified. - Visual-only indicators: the field border turns red or an exclamation icon appears, but no text alternative or ARIA label is provided.
- Error description is missing or unclear: the error says
Invalid input
without explaining what valid input looks like (e.g., required format for date, phone number, or email). - Programmatic association missing: error text is visually near the field but not associated via
aria-describedby,aria-errormessage, or proper labeling, so assistive technologies do not announce it automatically.
How to Fix It
Use oninvalid and oninput events for native HTML5 validation
The oninvalid event fires when a form field fails validation (e.g., required field is empty, pattern mismatch). The oninput event can clear or update error messages as the user corrects their input, providing immediate feedback and a better user experience.
<form aria-label="Log in">
<label for="username">Username (required, 3-20 characters)</label>
<input type="text"
id="username"
name="username"
required
pattern="[A-Za-z0-9]{3,20}"
oninvalid="this.setCustomValidity('Please enter a username that is 3-20 characters long (letters and numbers only).')"
oninput="this.setCustomValidity('')">
</form><form aria-label="Log in">
<label for="username">Username (required, 3-20 characters)</label>
<input type="text"
id="username"
name="username"
required
pattern="[A-Za-z0-9]{3,20}">
<script>
const usernameInput = document.getElementById('username');
usernameInput.addEventListener('invalid', (e) => {
const eventTarget = e.target;
if (eventTarget.validity.valueMissing) {
eventTarget.setCustomValidity('Username is required.');
} else if (eventTarget.validity.patternMismatch) {
eventTarget.setCustomValidity('Username must be 3-20 characters using only letters and numbers.');
}
});
usernameInput.addEventListener('input', (e) => {
const eventTarget = e.target;
eventTarget.setCustomValidity(''); // Clear error as user types
});
</script>Provide explicit error text and associate it with the invalid field
When an error is detected, display clear text that identifies the specific field and describes the error. Use aria-describedby or aria-errormessage to programmatically associate the error message with the invalid input.
<label for="email">Email address</label>
<input type="email" id="email" name="email"
aria-describedby="email-error"
aria-invalid="true">
<div id="email-error" class="error-message">
Error: Please enter a valid email address (e.g., name@example.com).
</div>Use aria-errormessage (modern approach)
The aria-errormessage attribute explicitly identifies the element containing the error message for the current field.
<label for="phone">Phone number</label>
<input type="tel" id="phone" name="phone"
aria-errormessage="phone-error"
aria-invalid="true">
<span id="phone-error" role="alert">
Error: Phone number must be 10 digits, no spaces or dashes.
</span>Provide a summary of errors with links to invalid fields
At the top of the form, list all errors with links that move focus to the corresponding invalid field.
<div class="error-summary" role="alert">
<h2>There were errors on your submission</h2>
<ul>
<li><a href="#email">Email: Please enter a valid email address</a></li>
<li><a href="#password">Password: Must be at least 8 characters</a></li>
</ul>
</div>
<label for="email">Email</label>
<input type="email" id="email" aria-describedby="email-summary-error"><!-- No text error message, only visual styling -->
<label for="username">Username</label>
<input type="text" id="username" style="border: 2px solid red;">
<!-- No error text anywhere --><div class="error">Submission failed. Please fix errors.</div>
<label for="email">Email</label>
<input type="email" id="email">
<label for="age">Age</label>
<input type="number" id="age">
<!-- User does not know which field(s) caused the error -->Live regions for dynamic error detection
For real-time error detection (e.g., on blur or as the user types), use role="alert" or aria-live="polite" to announce errors to screen readers without requiring form submission.
<label for="confirm-password">Confirm password</label>
<input type="password" id="confirm-password"
aria-describedby="pw-match-error">
<div id="pw-match-error" role="alert" aria-live="polite"></div>
<!-- JavaScript updates the div content when mismatch is detected -->Known Limitations
- Automated detection impossible: this rule cannot automatically determine whether error messages exist or are correct. It only flags form fields that may require error handling. A human tester must manually verify compliance.
- Client-side vs. server-side detection: this rule flags fields regardless of whether validation occurs on the client or server. Server-side errors must also comply, but testing requires form submission and may need a backend environment.
- Timing of detection: some forms detect errors only on form submission, others on blur, keypress, or in real-time. The manual verification must cover all validation triggers present in the application.
- Dynamic forms: fields added or removed dynamically after page load are still flagged if they match the selector at the time of the audit. However, the manual test must account for all possible form states.
- Conditionally hidden fields: the selector excludes
[hidden]attributes, but fields hidden via CSS (e.g.,display:noneorvisibility:hidden) may still be flagged. Testers should verify whether these fields are ever visible and require validation.
Resources
- Understanding WCAG SC 3.3.1: Error Identification (Level A)
- WAI Web Accessibility Tutorials: Form Notifications and Error Messages
- MDN Web Docs: aria-errormessage
- W3C WAI-ARIA 1.2: aria-errormessage
- WCAG 2.2 Success Criterion 3.3.1 (identical to 2.1)
Rule
- Audit: Accessibility
- Standard: WCAG 2.1 / WCAG 2.2
- Level: A
- Success Criteria: 3.3.1 Error Identification
- ID:
error-identification - Type: Manual verification (requires human testing)