I made a form in Laravel and added validation rules in the store()
method.
The validation works because when I submit invalid data, the page refreshes and the form doesn’t submit — but I don’t see any error messages on the page.
Here’s part of my form in Blade:
<form action="{{ route('register') }}" method="POST">
@csrf
<input type="text" name="name" placeholder="Name">
<button type="submit">Register</button>
</form>
And the validation inside my request file:
public function rules()
{
return [
'name' => 'required|min:3',
];
}
I tried using @error('name')
inside my form, but it still doesn’t display anything.
I expected to see the validation message like “The name field is required.” but the form just reloads.
How can I properly show Laravel validation errors in a Blade view?