Loading video...

Video Failed to Load

Go Home

Adding form validation to your React app? Try the "reward early, punish late" pattern 🏆

36,764 views • 2 years ago •via X (Twitter)

11 Comments

Ben Holmes's profile picture
Ben Holmes2 years ago

You can codegen this for any app using simple-form!

Ben Holmes's profile picture
Ben Holmes2 years ago

Got a full code walkthrough using Astro and Next.js!

Jamon's profile picture
Jamon2 years ago

I love these types of subtle UX improvement tips.

Deadlock's profile picture
Deadlock2 years ago

These features already available in react-final-form. it's an underdog for form state management as well as light weight package

KEV MOK's profile picture
KEV MOK2 years ago

Really top quality video. Have you thought of using Zod with your form validations?

Ben Holmes's profile picture
Ben Holmes2 years ago

@LinkedKev Not just *thought* about it. I made a wrapper library 😄

Brian Jordan's profile picture
Brian Jordan2 years ago

This has brought me psychic peace, always felt like early early was wrong but not sure why

Tracy Lee | ladyleet's profile picture
Tracy Lee | ladyleet2 years ago

Great video, Ben!!!

John Forte's profile picture
John Forte2 years ago

Yep, this is why most form packages have isTouched (onBlur) or isDirty (after user modifies field) to allow you to implement things like this.

Magne's profile picture
Magne2 years ago

what about checking on input but only after user stops typing? solves both cases I think

Ben Holmes's profile picture
Ben Holmes2 years ago

Sounds like validating on a debounce. That's nice sometimes as well! Still, it assumes the user is able to type at a certain speed, and it's hard to dial in an accessible value. Waiting for blur makes certain you validate once the user is done

Related Videos