Laravel Password and Confirm Password Validation Example
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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel 10 Ajax Form Validation Example Tutorial
- Laravel 10 Form Validation Tutorial Example
- Laravel Contact Form Send Email Tutorial
- Laravel Validation Allow Only Numbers Example
- Laravel Unique Validation on Multiple Columns Example
- Laravel Unique Validation With Soft Delete Example
- Laravel Unique Validation on Update Example
- Laravel Form Validation Request Class Example
- Laravel Mobile/Phone Number Validation Example
- Laravel Validation Check If Value is Not Equal to a Another Field
- Laravel Change Password with Current Password Validation Example
- Laravel File Upload with Validation Example
- Laravel Client Side Validation using Parsley.js Example