vee-validate 检查每个字符
vee-validate check after each character
是否可以在每个输入字符后执行此操作?
仅当您单击某处时检查才有效
密码:
<div class='form-group' :class='{"form-group_invalid": errors.has("password") && errors.has("password:min")}'>
<input
v-validate='"required|min:8|confirmed:password_confirmation"'
type='password'
name='password'
v-model='user.password'
ref='password'
/>
<div class='form-group__error'>{{ errors.first('password') }}</div>
</div>
密码确认:
<div class='form-group' :class='{"form-group_invalid": errors.has("password:confirmed")}'>
<input
v-validate='"required|confirmed:password"'
type='password'
name='password_confirmation'
v-model='user.passwordConfirmation'
ref='password_confirmation'
/>
<div class='form-group__error'>{{ errors.firstByRule('password', 'confirmed') }}</div>
</div>
您可以通过添加一个额外的属性来实现:
data-vv-validate-on="blur"
或者在您创建 VeeValidate 实例的 main.ts 中全局更改它
Vue.use(VeeValidate, {
events: 'change|custom'
});
是否可以在每个输入字符后执行此操作? 仅当您单击某处时检查才有效
密码:
<div class='form-group' :class='{"form-group_invalid": errors.has("password") && errors.has("password:min")}'>
<input
v-validate='"required|min:8|confirmed:password_confirmation"'
type='password'
name='password'
v-model='user.password'
ref='password'
/>
<div class='form-group__error'>{{ errors.first('password') }}</div>
</div>
密码确认:
<div class='form-group' :class='{"form-group_invalid": errors.has("password:confirmed")}'>
<input
v-validate='"required|confirmed:password"'
type='password'
name='password_confirmation'
v-model='user.passwordConfirmation'
ref='password_confirmation'
/>
<div class='form-group__error'>{{ errors.firstByRule('password', 'confirmed') }}</div>
</div>
您可以通过添加一个额外的属性来实现:
data-vv-validate-on="blur"
或者在您创建 VeeValidate 实例的 main.ts 中全局更改它
Vue.use(VeeValidate, {
events: 'change|custom'
});