Loading video...

Video Failed to Load

Go Home

Tailwind Tip #5 ✨ You can use ":invalid" pseudo class to create a pure css Tailwind CSS form validation without javascript. View code 👇 (5/30) follow for 25 more tips 😊

169,280 views • 3 years ago •via X (Twitter)

10 Comments

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

Join my personal newsletter ↓

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

💡You might want to remove "novalidate" from the <form> so that users cannot submit using keyboard "tab"

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

💡 You can also add the invalid class as a custom variant to declutter your html. Here's the updated version:

Dominik Geimer's profile picture
Dominik Geimer3 years ago

@tailwindcss Really like your tips! Keep going!

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

@tailwindcss Thanks Dominik!

jeff pohlmeyer's profile picture
jeff pohlmeyer3 years ago

@tailwindcss Holy hell, that's a lot of modifiers. There's got to be a better way than something like `[&:not(:placeholder-shown):not(:focus):invalid~span]:block`

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

@tailwindcss you can simplify it using tailwind-config by creating custom variants. See ↓

Khanif Ikhsanudin's profile picture
Khanif Ikhsanudin3 years ago

@tailwindcss for simple validation its ok, but for complex validation you have to use javascript

Surjith S M ✪'s profile picture
Surjith S M ✪3 years ago

@tailwindcss Yes + server side validation is a must.

#RelaxedGuy🇺🇬's profile picture
#RelaxedGuy🇺🇬3 years ago

@tailwindcss Hey man really waited for the dribble page I shared to be put to life

Related Videos