Skip to main content
InteractionLevel 3

Inline Validation

即时校验

WebMobileDesktopDifficulty: Medium

Tell the user while they type whether the value is right, instead of waiting until they submit.

01

Live Demo

Actually clickable

At least 8 characters

Click the field then move the mouse away (blur) — only then does it validate. Notice the error message says how to fix it.

What you just saw:Typing an email and seeing a checkmark with "Format looks good" appear as you go, then "Enter a complete email address" on blur; a live-updating "Password strength: medium" under the password field.

02

What it actually is

Timing is the whole game with inline validation: erroring on every keystroke as the user types is the most irritating version of it, and validating on blur and submit is the correct one. Its difference from form validation is about where and when the message appears.

inline validationlive validationinput validationreal-time validationfield validation
03

Anatomy · What it's made of

  1. Field输入框

    Red border in the error state

  2. Message提示信息

    Red or green, explains how to fix it

  3. Icon状态图标

    Check or bang, never the only signal

  4. Timing时机

    On blur or submit, never per keystroke

04

When to Use

When it fits, and when it doesn't
Inline Validation usage recommendations
SituationUse it?
The input has a hard format constraintYes
Errors can be detected automatically with an actionable fixYes
The form is long and filling it in is costlyYes
Errors can only be known after submittingDepends
The rules would fire an error on every keystrokeNo

Do not flash red the moment the user starts typing — let them finish first, then judge.

The message should tell the user how to fix it, not merely where the problem is.

05

Similar Patterns

Don't mix these up
06

How to tell AI

Three levels of prompt

Add the component name and specifics

Validate an email field on blur: when it is valid show a green check plus "Format looks good", when it is not show a red border plus "Enter a complete email address containing @".

07

Don't just say this to AI

Bad → Better

Don't say this to AI

Check the format while typing.

Say this instead

Add Inline Validation: validate only on blur and submit (never report an error from onChange on every keystroke), write error copy as an actionable fix ("Must contain @" rather than "Invalid format"), pair a red border with the error text plus aria-invalid and aria-describedby, and show a green check when the value is valid.

08

Share this card

Social-ready

Turn this pattern into a 3:4 or 1:1 knowledge card and export it as PNG right in the browser. No backend needed.