How To Make The Password_confirmation Error Show At The Right Field In Laravel (*)

- the current implementation not that great because when using confirmed means that any errors you get from the confirmed field will display at the parent input.

1- controller

$rules = [
  'password'              => 'required|min:6',
  'password_confirmation' => 'required_with:password|same:password',

2- view

<!-- password -->
<fieldset class="form-group">
  {{ Form::label('password', 'password :') }}
  {{ Form::password('password') }}
  @if ($errors->has('password'))
    <strong>{{ $errors->first('password') }}</strong>

<!-- password_confirmation -->
<fieldset class="form-group">
  {{ Form::label('password_confirmation', 'password_confirmation :') }}
  {{ Form::password('password_confirmation') }}
  @if ($errors->has('password_confirmation'))
    <strong>{{ $errors->first('password_confirmation') }}</strong>


  • as you can see nothing changed except the validation rules.
    you can also use the below to make the errors more user friendly ,just add them to your language validation file
'custom' => [
  'password_confirmation' => [
    'required_with' => 'The password confirmation field is required.',
    'same'          => 'The password confirmation and password must be of the same value.',

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.