正在加载视频...

视频加载失败

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 次观看 • 3 年前 •via X (Twitter)

10 条评论

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

Join my personal newsletter ↓

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

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

Dominik Geimer 的头像
Dominik Geimer3 年前

@tailwindcss Really like your tips! Keep going!

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Thanks Dominik!

jeff pohlmeyer 的头像
jeff pohlmeyer3 年前

@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 ✪ 的头像
Surjith S M ✪3 年前

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

Khanif Ikhsanudin 的头像
Khanif Ikhsanudin3 年前

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

Surjith S M ✪ 的头像
Surjith S M ✪3 年前

@tailwindcss Yes + server side validation is a must.

#RelaxedGuy🇺🇬 的头像
#RelaxedGuy🇺🇬3 年前

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

相关视频