ItSolutionStuff.com

Laravel Password and Confirm Password Validation Example

By Hardik Savani • October 12, 2023
Laravel

Hi Guys,

In this guide, we are going to learn laravel password and confirm password validation. Here you will learn confirm password validation in laravel. you can understand a concept of password and confirm password validation in laravel. I explained simply step by step laravel password confirmation doesn't match. follow the below example for check password and confirm password in laravel.

Laravel provides default confirmed validation to check password and confirm password validation. you must have to give input name password and password_confirmation, so that way it will works.

I will give you simple code that way you can understand how it will works:

Controller Validation Code:

/**

* Create a new controller instance.

*

* @return void

*/

public function store(Request $request): RedirectResponse

{

$this->validate($request, [

'name' => 'required',

'email' => 'required|email',

'password' => 'required|confirmed|min:6',

'password_confirmation' => 'required'

]);

}

Blade File Code:

<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">

<label class="col-md-4 control-label">Password</label>

<div class="col-md-6">

<input type="password" class="form-control" name="password">

@if ($errors->has('password'))

<span class="help-block text-danger">

<strong>{{ $errors->first('password') }}</strong>

</span>

@endif

</div>

</div>

<div class="form-group{{ $errors->has('password_confirmation') ? ' has-error' : '' }}">

<label class="col-md-4 control-label">Confirm Password</label>

<div class="col-md-6">

<input type="password" class="form-control" name="password_confirmation">

@if ($errors->has('password_confirmation'))

<span class="help-block">

<strong>{{ $errors->first('password_confirmation') }}</strong>

</span>

@endif

</div>

</div>

Output:

I hope it can help you...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel 10 Ajax Form Validation Example Tutorial

Read Now →

Laravel 10 Form Validation Tutorial Example

Read Now →

Laravel Contact Form Send Email Tutorial

Read Now →

Laravel Validation Allow Only Numbers Example

Read Now →

Laravel Unique Validation on Multiple Columns Example

Read Now →

Laravel Unique Validation With Soft Delete Example

Read Now →

Laravel Unique Validation on Update Example

Read Now →

Laravel Form Validation Request Class Example

Read Now →

Laravel Mobile/Phone Number Validation Example

Read Now →

Laravel Validation Check If Value is Not Equal to a Another Field

Read Now →

Laravel Change Password with Current Password Validation Example

Read Now →

Laravel File Upload with Validation Example

Read Now →

Laravel Client Side Validation using Parsley.js Example

Read Now →