skip to content

Validation Timing & Rules

When a rule runs — at submit, on blur, on every change, or on change once a submit failed — and when its verdict may show. Probed because timing is what makes a form feel fair.

on this pageshow

questions

6

In a form, what are the moments a validation rule can run - submit, blur, or change - and how does each choice change the form's feel?

level: juniorimportance: must knowfreq 76%

answer

  1. four moments, not one
  2. leaving a field is the polite moment
  3. submit, blur, change
  4. reward early, punish late

basics

~20 s

A rule can run when the form is submitted, when a field loses focus, on every value change, or on change only after a submit has failed. Later timing feels calmer; earlier timing corrects sooner but interrupts typing.

solid answer

~50 s

There are four moments worth knowing. **On submit**: every rule runs once when the user tries to send the form - quiet while typing, but the user meets a wall of errors at the end. **On blur**: a field's rule runs when the field loses focus, which is a natural pause, so feedback lands per field without interrupting. **On change**: the rule runs on every value change, which is immediate but judges half-typed values, so an email is called invalid three times before it is finished. **On change after a failed submit**: rules stay quiet until the first submit attempt, then the failing fields switch to per-change checking so an error clears the moment it is fixed - often summarised as reward early, punish late. Most forms default to blur plus submit, and use per-change only where the value is judged character by character, such as a password strength meter.

go deeper

for a junior

Recall the menu: submit, blur, every change, and change-after-a-failed-submit. Know that blur plus submit is the usual default and that per-keystroke format errors annoy users.

for a middle

Explain why running a rule and showing its verdict are separate steps, and which per-field bookkeeping gates the display. Argue timing per field type rather than per form.

for a senior

Show the judgment: which fields earn live feedback, which rules are too expensive for per-change running, and how the submit path still re-validates everything so an untouched field cannot slip through.

for a principal

Frame it as a product convention, not a per-form choice: one timing policy across the design system, so error behaviour is predictable, and a documented exception list for live indicators and expensive rules.

Validation has two separate questions hiding inside it: **when does the rule run**, and **when may its verdict be shown**. This item is about the first, and about the feel each choice produces. A rule here means any check a framework runs over a field's current value - a required check, a length or format check, a comparison with another field - independent of anything the host platform does on its own. ## The four moments - **On submit.** Every field's rule runs once, when the user tries to send the form. Nothing interrupts typing, and the form never accuses a value the user has not finished entering. The cost is that the whole verdict arrives at once, at the least convenient moment, often as several messages the user must now hunt down. - **On blur (the field loses focus).** The rule for that one field runs when the user leaves it. Leaving a field is the user's own signal that they consider it finished, so the verdict reads as fair. Feedback is scoped to one field at a time, and the user is corrected while the field is still fresh in mind. - **On change (every value change).** The rule runs on each edit. Feedback is instant, which suits values judged progressively - a strength meter, a character counter, a slug preview. It is a poor default for format rules, because a partly typed value is legitimately not yet valid: an email address is invalid at every keystroke until it is not. - **On change only after a failed submit.** Rules run silently, or not at all, until the first submit attempt fails. From then on, the fields that failed re-check on every change, so a standing error can disappear on the keystroke that repairs it. The shorthand is **reward early, punish late**: be quick to clear an error, slow to raise one. | Timing | When the rule runs | How it feels | |---|---|---| | On submit | Once for every field, on the submit attempt | Calm while typing; a pile of errors at the end | | On blur | For one field, when it loses focus | Per-field feedback at a natural pause | | On change | On every value change | Immediate, but nags at half-typed values | | On change after a failed submit | Silently at submit, then per change for failing fields | Forgiving early, precise once something is wrong | ## Running a rule is not the same as showing its verdict A framework may compute a verdict long before it is allowed to display one. A required rule over an empty field is already failing on page load, yet a form that shows that error immediately looks broken - the user has not done anything wrong yet. So forms keep per-field bookkeeping (a visited or touched flag, a changed or dirty flag, a submit-attempted flag) and use it to gate **display**, while the rule itself may run as often as is cheap. Treating the two as one thing is the most common mistake in this area: people avoid running rules early because they think running implies showing. ## Choosing per field, not per form The timing is usually a per-field decision, driven by how expensive the value is to get right: 1. **Free-form text with a format** - blur, then per change once it has failed. Judging mid-word is unfair. 2. **Constrained pickers and toggles** - on change is fine, because every value is complete by construction. 3. **Values a human must compose over several keystrokes** (passwords, card numbers, long codes) - a live indicator may run on change while the hard error still waits for blur or submit. 4. **Rules that cost something** - a check that calls a server, or that walks a large structure, should not run on every keystroke; it needs debouncing and a pending state of its own. ## What each choice costs - Per-change rules run orders of magnitude more often than per-blur rules. On a runtime that re-runs the component function per state write, a rule attached to that path runs on the same cadence; on one with fine-grained tracking, only the subscribers of that value re-run - but the rule itself still executes per change either way. - Submit-only validation makes the form cheap and predictable, and is often the right default on a long form where the user wants to type uninterrupted. - A form that mixes strategies must still produce one coherent story at submit: the submit path re-runs everything, because a field the user never visited has no verdict yet. - Where the host platform performs its own submit-time checking, a form that takes validation over must also take over the moment of refusal, or the two can disagree about whether the submission proceeds. The practical default most design systems land on: validate on blur, re-validate on change once a field has an error, and always re-validate everything at submit.

  • Why is validating on every change a poor default for a format rule such as an email address?
    Because a partly typed value is legitimately not valid yet. The rule is right and the message is still wrong: the user is told they made a mistake while they are in the middle of not having made one. The same rule becomes useful the moment the field has been left, or once a submit has already failed and the user is repairing a known error.
  • The submit path already re-runs every rule. Why bother validating earlier at all?
    To shorten the loop. Errors found at submit arrive together, far from the moment the value was typed, and the user has to re-enter a mental context for each one. Earlier timing spreads the same verdicts out to the point where each is cheap to fix. Submit-time validation remains mandatory, because untouched fields have no earlier verdict.
  • Does a rule running on page load mean the user sees an error on page load?
    No. Running and showing are separate steps. Forms keep flags for whether a field has been visited, whether its value changed, and whether a submit was attempted, and use those to decide whether a computed verdict may be displayed. A required rule over an empty field can be failing quietly from the first render.

A proofreader who interrupts you mid-word versus one who waits for the sentence to end. Both find the same typo; only one is bearable to write next to.

saying these in an interview costs you the question

  • Thinks validation can only happen at submit time
  • Validates on every keystroke by default and calls it responsive
  • Assumes a rule that has run must show its error
  • Shows required-field errors on an untouched, freshly loaded form
  • Picks one timing for the whole form regardless of field type
  • Skips submit-time validation because fields were checked on blur
open as a page

In a form, what do the touched and dirty flags track, and why does a field's error message wait on one of them?

level: middleimportance: must knowfreq 66%

basics

~20 s

Touched means the field was focused and then left; dirty means its value differs from its initial value. Error display is gated on touched or a submit attempt, so a verdict is not shown before the user has had a turn.

open as a page

Where does a cross-field rule such as confirm-password or a start-before-end date range attach, and when must it re-run?

level: middleimportance: should knowfreq 52%

basics

~20 s

It attaches to the group that holds both values, or to one field that declares a dependency on the other, and it must re-run when either participant changes - not only the field the user edited, or its error goes stale.

open as a page

Once a field displays an error, what must the form do so the message disappears on the keystroke that fixes the value?

level: middleimportance: should knowfreq 56%

basics

~20 s

Re-run that field's rule on every change while an error is standing, and clear the message as soon as the rule passes. Waiting for the next blur or submit leaves a stale error on an already-correct value.

open as a page

A field's rule must ask a server whether a value is already taken; what does that asynchronous rule need beyond a synchronous one?

level: seniorimportance: should knowfreq 54%

basics

~20 s

It needs a debounce, cancellation of superseded requests, a pending state that is neither valid nor invalid, a check that the reply still matches the current value, and a submit path that accounts for it.

open as a page

Would you define a form's validation rules once and share them with the server, or keep two sets, and what does each choice cost?

level: principalimportance: should knowfreq 44%

basics

~20 s

Share one declarative definition for the constraints both sides can express, and accept the coupling. Rules needing data only the server holds stay there. The server validates again regardless; the client's verdict is a preview.

open as a page