<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa" -->

---
title: Form validation: reward early, punish late | daily.dev
description: A UX and implementation pattern for form validation called 'reward early, punish late': validate on blur so users aren't interrupted mid-typing, but hide...
canonical: https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Form validation: reward early, punish late | daily.dev
og:description: A UX and implementation pattern for form validation called 'reward early, punish late': validate on blur so users aren't interrupted mid-typing, but hide...
og:url: https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa
og:image: https://api.daily.dev/og/posts/mmZblwCQA.png
og:image:alt: Form validation: reward early, punish late
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Form validation: reward early, punish late

**[UX/UI](https://daily.dev/sources/uxui)** · [@a_dev0](https://daily.dev/a_dev0) · 2 min read · 0 upvotes · 0 comments

## Summary

A UX and implementation pattern for form validation called 'reward early, punish late': validate on blur so users aren't interrupted mid-typing, but hide errors immediately once they start correcting a field rather than waiting for another blur or submit. The approach separates creating, showing, and clearing errors as distinct actions—no error is created until the user has typed something, errors show only after blur, and server errors clear as soon as either related field (email or password) changes. Built with TanStack Form 1.x and Zod, using a single `onDynamic` validator via `validationLogic` to avoid duplicate messages that occurred when separate `onBlur` and `onChange` validators were used. The author also discusses classifying auth errors to keep 400/401 responses ambiguous and acknowledges trade-offs, like a server error disappearing before a fast typist can read it.

## Content

IMO, most login forms disturb you at the wrong time. They show a red "Invalid email" message while you're still halfway through typing, or say nothing until you press the button. Then the error sits there while you fix it.

The principle is "reward early, punish late". Validate on blur, which feels like a fair time to flag an invalid value. Hide the error as soon as the user starts fixing it, without waiting for the next blur or submit. We don't yet know whether they've fixed it. That takes another validation check.

Article: [https://dev.to/a-dev/choreography-of-validation-how-to-make-your-auth-form-seamless-and-usable-1dpm](https://dev.to/a-dev/choreography-of-validation-how-to-make-your-auth-form-seamless-and-usable-1dpm)

Demo: [https://a-dev.github.io/probes/validation/](https://a-dev.github.io/probes/validation/)

You control when to create, show, and clear an error separately:

- Don't create an error until the user has typed something. Clicking into an empty field and leaving it untouched shouldn't trigger one.
- Show the error after blur and hide it while the user edits the field.
- Clear a server error as soon as either the email or password changes. The server's response applies to the pair it checked.

In this example, I use TanStack Form 1.x and Zod. The idea also applies to other stacks. TanStack Form's `validationLogic` with a single `onDynamic` validator worked for this. I first tried separate `onBlur` and `onChange` validators and got duplicate messages because TanStack stores errors per trigger and flattens them.

The article includes the full `rewardEarlyPunishLate` implementation and a small display hook. I also explain how I classify auth errors to keep 400/401 messages deliberately ambiguous, and discuss the trade-offs I'm not happy about. For example, a server error can disappear before a fast typer reads it.

I'm interested in your thoughts on this approach. Also, please share how you keep form validation from annoying your users.

## Similar posts on daily.dev

- [How building an HTML-first site doubled our users overnight](https://daily.dev/posts/how-building-an-html-first-site-doubled-our-users-overnight-jytz7gmbg) · Lobsters · 0 upvotes · 0 comments
- [Stop fighting forms: The schema-driven approach to validation](https://daily.dev/posts/stop-fighting-forms-the-schema-driven-approach-to-validation-8vq511w0o) · LogRocket · 1 upvotes · 0 comments
- [A Guide to Modern React Form Architecture: TanStack Form \+ Zod \+ Shadcn](https://daily.dev/posts/a-guide-to-modern-react-form-architecture-tanstack-form-zod-shadcn-osvxw2xhz) · freeCodeCamp · 7 upvotes · 0 comments
- [Form Automation Tips for Happier User and Clients](https://daily.dev/posts/form-automation-tips-for-happier-user-and-clients-0hnzjjnjl) · CSS-Tricks · 1 upvotes · 0 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#ux](https://daily.dev/tags/ux), [#zod](https://daily.dev/tags/zod)

[View this post on daily.dev](https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa","headline":"Form validation: reward early, punish late","text":"A UX and implementation pattern for form validation called 'reward early, punish late': validate on blur so users aren't interrupted mid-typing, but hide errors immediately once they start correcting a field rather than waiting for another blur or submit. The approach separates creating, showing, and clearing errors as distinct actions—no error is created until the user has typed something, errors show only after blur, and server errors clear as soon as either related field (email or password) changes. Built with TanStack Form 1.x and Zod, using a single `onDynamic` validator via `validationLogic` to avoid duplicate messages that occurred when separate `onBlur` and `onChange` validators were used. The author also discusses classifying auth errors to keep 400/401 responses ambiguous and acknowledges trade-offs, like a server error disappearing before a fast typist can read it.","url":"https://daily.dev/posts/form-validation-reward-early-punish-late-mmzblwcqa","datePublished":"2026-09-23T11:37:32.694Z","dateModified":"2026-09-23T11:38:26.830Z","author":{"@type":"Person","name":"a-dev","url":"https://daily.dev/a_dev0","image":"https://media.daily.dev/image/upload/s--s0sr9Blf--/f_auto/v1787148202/avatars/avatar_kC75ItpSnNiyj3fJ7XTxr?_a=BAMAMicg0","description":"Frontend-heavy fullstack engineer. Love CSS. Love TS.","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":170}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/uxui","name":"UX/UI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"UX/UI","item":"https://daily.dev/squads/uxui"},{"@type":"ListItem","position":3,"name":"Form validation: reward early, punish late"}]}
```

