Summer Sale! All accounts are 50% off this week.

zeroX's avatar
Level 6

Validation Errors with Tailwind

Hello,

is it possible to add for example the tailwind class "border-red-500" to a input that has errors after validation with plain Laravel and Tailwind or do i need to use JS or Vue for something like that?

What is the common approach for cases like that? I don't need a solution, a hint what to learn next or a little tip is enough.

Thank you very much an be safe out there.

0 likes
3 replies
Ksandar's avatar
Ksandar
Best Answer
Level 26

@bensen you can use the standard @error blade directive, as is done in the basic login page view, like this:

<input class="form-control @error('email') border-red-500 @enderror" name="email">

using vue or js is not necessary for this

About this @error blade directive you can read here

Snapey's avatar

use a blade @error to insert the class. What version are you on?

zeroX's avatar
Level 6

Amazing. Thank you very much. I thought too complex instead of looking at blade!

Have a very good day.

1 like

Please or to participate in this conversation.