I'm trying to use vee validate to verify the password using this code.
<div>
<input type="password"
placeholder="Password"
v-model="password"
v-validate="'required|min:6|max:35|confirmed'"
name="password" />
</div>
<div>
<span>{{ errors.first('password') }}</span>
</div>
<div>
<input type="password"
placeholder="Confirm password"
v-model="confirmPassword"
v-validate="'required|target:password'"
name="confirm_password" />
</div>
<div>
<span>{{ errors.first('confirm_password') }}</span>
</div>
But it always says The password confirmation does not match. What went wrong in my code?
any help
Thanks in advance.
There's an error with the Vee Validate syntax, change
target:
toconfirmed:
v-validate="'required|target:password'"
should be
v-validate="'required|confirmed:password'"
Also, your password input must have
ref="password"
- that's how vee-validate finds the target:<input v-validate="'required'" ... ref="password">
(Thanks, Ryley).Have a look at the basic example below, it will check for two things:
Further reading: https://baianat.github.io/vee-validate/guide/rules.html#confirmed