KarlHill69's avatar

Password confirmation doesn't work

Hello. My password confirmation doesn't work in form submission. Can you helpme. My code is-

class ResetPassword extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'password' => 'required|min:8',
            'password_confirmation' => 'required',
        ];
    }
}

Any tip?

1 like
5 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@karlhill69

You have to have password_confirmation filed in the password reset form.

And I believe you have to use confirmed also.

For example-

return [
            'password' => 'required|min:8|confirmed',
            'password_confirmation' => 'required',
        ];

Instead of

return [
            'password' => 'required|min:8',
            'password_confirmation' => 'required',
        ];
10 likes
MichalOravec's avatar

@tisuchi Yeah, but it doesn't matter, because they have to match. And password is required which means if you don't fill password_confirmation field than confimed validation rule fail.

2 likes
tisuchi's avatar

@michaloravec

Yeah, I got it. I understood your comment wrongly. I take off already.

Thanks, mate :)

5 likes
danilocgsilva@gmail.com's avatar

Differentiating between the "password" and the "password confirmation" should be possible. Telling the user that registration failed because the password doesn’t meet the minimum security requirements is quite different from telling them that the password confirmation don’t match. It would be ideal to display the validation error message next to the password field when it doesn’t meet the requirements, and show the confirmation mismatch error message below the confirmation field when the password meets the minimum requirements but the confirmation doesn’t match. I can’t do this if the password requirements and the password confirmation are treated as the same thing.

Please or to participate in this conversation.