Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lucious123's avatar

Validation Errors Not Showing in Blade Template

Hello everyone,

I'm facing an issue where validation errors are not displaying in my Blade template. Below is my code:

login.blade.php

<div class="form-group">
    <div class="input-group input-group-merge">
        <div class="input-icon">
            <span class="ti-mobile"></span>
        </div>
        <input type="tel" name="phone" class="form-control" required placeholder="Enter Your Phone Number">
    </div>
</div>

@error('phone')
       <p class="text-danger"><small>{{ $message }}</small></p>
@enderror

LoginController.php

$request->validate([
    'phone' => 'string|required|exists:api_users,phone',
    'password' => 'string|required|min:8'
], [
    'phone.exists' => 'This phone number doesn\'t match our records',
]);

The validation should trigger an error message when an invalid phone number is entered, but the message is not showing in the Blade view.

I would appreciate any guidance on what might be causing this issue. Thank you!

0 likes
2 replies
tisuchi's avatar

@lucius123 Can you check whether you get a validation error if fails?

// Your validation 

if ($validator->fails()) {
    return redirect()->back()->withErrors($validator)->withInput();
}

Also, make sure you are using the POST method in the form with the @csrf token.

2 likes
Lucious123's avatar

@tisuchi Thanks for your answer, Sir. I found the issue— I had placed the login function inside the auth-user middleware, which made it work only for authenticated users and not for unauthenticated ones.

Please or to participate in this conversation.