Require a password confirmation in Vue

The confirmed rule checks password_confirmation. The Vue form needs that second field name.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-password-confirmed-vue.md
The confirmed rule checks password_confirmation. The Vue form needs that second field name.
Do not hash the password in the Vue page, and do not send a confirmation to a column.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel password confirmation Vue” add one password input and then the rule fails with no obvious bug. confirmed looks for a second field named {field}_confirmation.

TL;DR

  • The confirmed rule checks password_confirmation.
  • The Vue form needs that second field name.
  • Do not hash the password in the Vue page, and do not send a confirmation to a column.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

Password reset on the starter kit already has both fields. The Fortify guide is that flow. This page is the rule when you add a password field of your own.

php
use Illuminate\Validation\Rules\Password;

$validated = $request->validate([
    'password' => ['required', 'confirmed', Password::defaults()],
]);
vue
<input v-model="form.password" name="password" type="password" autocomplete="new-password" />
<input v-model="form.password_confirmation" name="password_confirmation" type="password" autocomplete="new-password" />
<p v-if="form.errors.password">{{ form.errors.password }}</p>

The error is attached to password, not to password_confirmation. One paragraph under the first field is enough.

What to avoid#

Gotcha

Do not hash the password in the Vue page, and do not send a confirmation to a column. Only password is stored, and the cast on the User model hashes it. If you also Hash::make() in the controller, the password is hashed twice and login fails.

FAQ#

How do I require a password confirmation in Vue?

The confirmed rule checks password_confirmation. The Vue form needs that second field name.

What goes wrong with Laravel password confirmation Vue?

Many developers add one password input and then the rule fails with no obvious bug. Do not hash the password in the Vue page, and do not send a confirmation to a column.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.