Laravel Password and Confirm Password Validation Example

By Hardik Savani October 12, 2023 Category : 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 :
Shares