Join WhatsApp ChannelJoin Now

Password and Confirm Password In Laravel 10

Hi dev,

Today, i show you password and confirm password in laravel 10. This article will give you simple example of password and confirm password in laravel 10. you will password and confirm password in laravel 10. In this article, we will implement a password and confirm password in laravel 10.

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.

you can use this example with laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version.

So, let’s follow few steps to create example of password and confirm password in laravel 10.

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>

I hope it will assist you…

Recommended Posts