Vee-validate: Validate Form Before Submit not submitting form when successful

Created on 1 Feb 2017  路  9Comments  路  Source: logaretm/vee-validate

Versions:

Description:

@submit.prevent="validateBeforeSubmit" rule is successfully triggering and alerting but does not submit the form after success.

Steps To Reproduce:

http://vee-validate.logaretm.com/examples#validate-form

Am I missing something?

Most helpful comment

Here I found the answer. This should be documented not the alert "Form submitted". Thank you @logaretm

validateBeforeSubmit(e) {
    e.preventDefault();
    this.$validator.validateAll().then(() => {
        // Data is valid, so we can submit the form.
        document.querySelector('#myForm').submit();
    }).catch(() => {
        return false
    });
}

All 9 comments

The form in the docs are prevented at all times, so it doesn't be disruptive when you read the docs, in the code example there is no need to prevent it after success.

I didnt add .submit() to my method so the form was not submitting sorry! Thanks for the work.

@benj3 How did you do it? My form also just alert "Form submitted" but it doesn't load the submission. TY

Here I found the answer. This should be documented not the alert "Form submitted". Thank you @logaretm

validateBeforeSubmit(e) {
    e.preventDefault();
    this.$validator.validateAll().then(() => {
        // Data is valid, so we can submit the form.
        document.querySelector('#myForm').submit();
    }).catch(() => {
        return false
    });
}

Yep this is what I was missing also :)

@bobbygerez

Thank you so much.. it works..

+1 Docs on this need to be extended.

How is this essential piece of code missing in the documentation?
Am i missing something ?

@maximusblade The docs had a lot of changes since this issue was closed. You probably should check the examples page

Was this page helpful?
0 / 5 - 0 ratings