Vee-validate: How to valitdate when form is submitted?

Created on 25 Jan 2017  Â·  6Comments  Â·  Source: logaretm/vee-validate

Versions:

  • VueJs: 2.1.0
  • Vee-Validate: 2.0.0-beta.19

Description:

I am searching for a simple way to have onSubmit validating. The only way i was able to do that was by creating isSubmitted flag and then make multiple tenery statements for each input field :)

Are there any way to disable the validation until some point when the form is submitted :) ?

✨ enhancement

Most helpful comment

You can add a data-vv-validate-on and assign it any non-html event name, the validation won't occur. so you would trigger them using validateAll.

<input v-validate="'required'|email'" name="email" data-vv-validate-on="none">

<form @submit.prevent="$validator.validateAll()"></form>

I might add a disable modifier for this purpose in next releases.

All 6 comments

You can add a data-vv-validate-on and assign it any non-html event name, the validation won't occur. so you would trigger them using validateAll.

<input v-validate="'required'|email'" name="email" data-vv-validate-on="none">

<form @submit.prevent="$validator.validateAll()"></form>

I might add a disable modifier for this purpose in next releases.

I'd love to be able to disable validation on _all_ fields!

As a follow up, data-vv-validate-on="none" doesn't work on inputs with a confirmed rule

@hatzipanis One option would be to add a long delay to the validation. This would keep the errors from showing until you trigger valdiateAll(), which will overwrite the delay.

However I would assume this will add timers for all your validated fields which might be a performance issue.

An option to disable real time validation would be a valuable addition in my eyes so we don't have to litter 'data-vv-validate-on="none"' all over our forms.

Has this even been fixed in a way we can validate on submit without adding data-vv-validate-on="none" everywhere?

@burzum have a look if this solves your issue:
https://github.com/baianat/Vee-validate/issues/469
A combination of .disable and $validator.validateAll() does the job for us.
It was already mentioned above but maybe the example in the linked issue is helpful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

parweb picture parweb  Â·  3Comments

Etheryte picture Etheryte  Â·  3Comments

the94air picture the94air  Â·  3Comments

biapar picture biapar  Â·  3Comments

jagasan picture jagasan  Â·  3Comments