kazupon / vue-validator

:white_check_mark: Validator component for Vue.js
MIT License
2.19k stars 431 forks source link

How to disabled submit button on page init #354

Open baiyunchen opened 7 years ago

baiyunchen commented 7 years ago

Vue Version:Vue 2.0 Vue-Validator Version:v3.0.0-alpha.2 when page init $validation is empty object,if i bind :disabled="reasonInvalid" to submit button,this can not work on page first init. How can I solve this problem?

gavrashenko commented 7 years ago

This demo can helps a little: vue-validator/examples/timing/index.html But: demo have some issue. If one of the fields is a valid - submit button will become active. Maybe you should add array to the data with all your validity fields, and mark them as valid/invalid durings validation (inside handleInput method), and unlock your submit button after all fields will become isValid: true

baiyunchen commented 7 years ago

@gavrashenko I think vue-validator need provider an API that can be invoked before submit it to obtain the validation results,this is be best practice.