Form validation is one of the most consequential UX decisions in web development. The same set of validation rules, implemented with two different timing strategies, can produce meaningfully different completion rates. Inline validation, where feedback appears field-by-field as users progress through a form, consistently outperforms submit-and-validate-all patterns for user experience and completion.
This article covers how inline validation works, when to use it, how to implement it correctly, and the specific patterns that make it effective versus counterproductive.
Why Submit-Time Validation Creates a Poor Experience
The traditional validation pattern, validate all fields when the user clicks submit, creates several compounding problems.
Error discovery is deferred. The user completes the entire form before learning anything is wrong. At that point they have the most invested in the task and the most to lose psychologically if they have to redo work.
Error location requires searching. Validation errors returned after submit are typically shown at the top of the form or highlighted inline, but the user must scroll back through the form to find each highlighted field. On a long form, this requires significant navigation. On mobile, it can feel like starting over.
Multiple errors appear simultaneously. When several fields fail validation at once, users face a list of errors to work through. Each one requires re-reading the instructions, locating the field, and correcting it. The cognitive and emotional cost compounds.
False success signals occur. A user who fills in a field incorrectly but receives no feedback until submitting believes the field is fine until the error appears. The correction feels like a reversal rather than a natural part of the process.
What Inline Validation Changes
Inline validation checks each field individually after the user leaves it (on blur). Feedback appears immediately below the field while the user is still in the context of that section of the form. Errors are corrected one at a time, at the moment of lowest cost.
The research on this is consistent. A landmark study by the Interaction Design Foundation and subsequent replications found that inline validation reduced errors by 22%, reduced completion time by 42%, and increased satisfaction scores compared to after-submit validation for the same form content. The gains are largest for long forms and forms with complex field requirements.
Web design agency 137Foundry implements inline validation as the default validation pattern on forms built for client projects. The principle is covered in our broader form design guide at 137foundry.com/articles/how-to-design-web-forms-users-complete, which covers field count, input types, mobile layout, and confirmation experience alongside validation strategy.
The Critical Implementation Detail: Validate on Blur, Not on Input
The most common inline validation mistake is triggering validation while the user is still typing (on the input event). This produces false errors constantly.
An email field checked on input will show "invalid email" the moment the user types a single character. A user who has not yet typed the @ symbol is not making an error; they are in the middle of typing. Checking at this point creates visual noise and anxiety without providing useful feedback.
The correct event to validate on is blur, which fires when the user moves focus out of the field. At that point, the user has finished entering their input and validation feedback is appropriate and timely.
document.querySelector('#email').addEventListener('blur', function () {
validateField(this);
});
For confirm-password or interdependent fields where one field's validity depends on another's value, you may need to re-validate one field when the other changes. For example, confirming that a "confirm password" field matches the password field should re-run when either field changes.
const password = document.querySelector('#password');
const confirm = document.querySelector('#confirm-password');
confirm.addEventListener('blur', () => validateMatch(password, confirm));
password.addEventListener('blur', () => {
if (confirm.value) validateMatch(password, confirm);
});
Error Message Placement and Content
Error messages should appear immediately below the field they describe, in the reading flow between the field and the next element. They should be visible without scrolling, associated with the field via aria-describedby for screen reader accessibility, and dismissed automatically when the user corrects the error.
Message content should be specific about what is wrong and what the correct format is:
<label for="phone">Phone number</label>
<input
type="tel"
id="phone"
aria-describedby="phone-error"
aria-invalid="true"
/>
<p id="phone-error" role="alert">
Enter a phone number with 10 digits, like 5551234567
</p>
The aria-invalid="true" attribute signals to screen readers that the field has an error. The role="alert" on the error paragraph causes screen readers to announce the message when it appears, without requiring the user to navigate to it. The Mozilla Developer Network provides the full reference for ARIA form patterns, and the Web Accessibility Initiative documents the accessibility requirements for form error identification.
Visual Design of Inline Validation States
Each field should have three visible states beyond the default: active/focused, valid, and error.
Active/focused: A clear focus ring that meets WCAG 2.1 contrast requirements. Do not remove the native focus ring without providing a visible alternative.
Valid: A subtle success indicator, typically a green checkmark or border color change, that appears when the user leaves a field after entering acceptable input. Keep this understated; a form that aggressively celebrates each correct field becomes noisy.
Error: A red border, error icon, and the error message. Red should not be the only indicator (for color-blind users); combine it with an icon and the text message.
Avoid using placeholder text to communicate required format or examples. Placeholder text disappears when the user starts typing, which means they cannot reference it if they are unsure what to enter. Visible hint text below the label, present before the user interacts with the field, is the correct pattern.
Testing Inline Validation With Automated Tools
Inline validation introduces dynamic content changes to the DOM, which means your standard HTML validation pass may not catch all issues. Testing should cover:
- Keyboard navigation: Tab through all fields and verify that error messages appear and are announced correctly without requiring a mouse.
- Screen reader testing: Use NVDA (on Windows) or VoiceOver (on macOS and iOS) to verify that errors are announced at the right moment and associated correctly with their fields.
- Automated accessibility checks: Tools like Axe (from deque.com) and the built-in browser DevTools accessibility panel catch missing ARIA attributes, insufficient color contrast, and unlabeled fields.
// Example: programmatically triggering validation for testing
function runValidationTests() {
const fields = document.querySelectorAll('[data-validate]');
fields.forEach(field => {
field.dispatchEvent(new Event('blur'));
});
}
The A11y Project maintains a checklist that covers the accessibility requirements for form validation states. WebAIM provides additional documentation on accessible form design and testing approaches.
When to Show Positive Confirmation
Not every field needs a success state. For fields where the validity criteria are simple and familiar (email, phone number, date), a success indicator after the user leaves the field provides reassurance that the input was accepted. For fields with complex or unusual requirements (password strength, specific numeric ranges), the success state after validation is more valuable because it confirms that the requirements were met.
For password fields, showing strength feedback while the user is typing (on the input event) is one of the few legitimate exceptions to the blur-validation rule, because the feedback is progressive and genuinely useful during input, not a false error.
password.addEventListener('input', function () {
updateStrengthMeter(this.value);
});
The Nielsen Norman Group has published specific research on password field design and strength meter usability that provides useful reference for this specific case.
Summary
Inline validation on the blur event, with specific error messages, correct ARIA attributes, and clear visual states, is consistently better than submit-time validation for both users and completion rates. The implementation is straightforward in vanilla JavaScript and can be adapted to any front-end framework. The gains in completion rate, user satisfaction, and error reduction are well-documented and reliably reproducible by applying the pattern correctly.
For the broader context on how validation fits into a complete form UX strategy, the 137Foundry services page covers the web design and development work where these patterns are applied in production.
Top comments (0)