Pablo Souza
Pablo Souza

Reputation: 893

VeeValidate - check validated input field to enable another input

Its my first time using VeeValidate. How can I enable/disable a form field just when another is valid. For example, just enable password field after veevalidate checks the user field as valid.

Upvotes: 0

Views: 556

Answers (1)

Ryley
Ryley

Reputation: 21226

Wrap both relevant fields in a ValidationObserver and use it's scoped prop errors to tell you when the one field is invalid. Something like this (untested):

<ValidationObserver v-slot="{ errors }">
    <ValidationProvider vid="item1" rules="required">
        <input v-model="item1" />
    </ValidationProvider>
    <ValidationProvider vid="item2" rules="required">
        <input v-model="item2" :disabled="errors.item1"/>
    </ValidationProvider>
</ValidationObserver>

Upvotes: 2

Related Questions