Home > Software engineering >  vee-validate check after each character
vee-validate check after each character

Time:10-22

Is it possible to do this after each input character? The check works only if you click somewhere

password:

    <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>

password confirm:

<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>

CodePudding user response:

You can achieve this by adding an extra attribute:

data-vv-validate-on="blur"

or by changing it globally in your main.ts where you create the VeeValidate instance

Vue.use(VeeValidate, {
  events: 'change|custom'
});
  • Related