I need to validate inputs only after a submit button is clicked. However, the required rule is activating after focus lost. I'm using VeeValidate in Vue.js.
HTML:
<input
name="Email"
v-validate
data-vv-rules="required|email"
id="email"
type="email"
v-model="email"
placeholder="Email "
>
JS:
this.$validator.validateAll().then(success => {
})
I need to validate inputs only after a submit button is clicked. However, the required rule is activating after focus lost. I'm using VeeValidate in Vue.js.
HTML:
<input
name="Email"
v-validate
data-vv-rules="required|email"
id="email"
type="email"
v-model="email"
placeholder="Email "
>
JS:
this.$validator.validateAll().then(success => {
})
Share
Improve this question
edited Mar 22, 2017 at 14:47
thanksd
55.7k23 gold badges165 silver badges154 bronze badges
asked Mar 22, 2017 at 13:20
MAXIMANMAXIMAN
1652 silver badges14 bronze badges
2
- could you post ur full js function .. – Abhinav Commented Mar 22, 2017 at 13:23
- From a UX standpoint, instant feedback after losing focus gives the form a nice interactive feel to it. This isn't the most helpful for the question but it's useful to be said. – Patrick Barr Commented Mar 22, 2017 at 13:28
2 Answers
Reset to default 3You can use data-vv-validate-on
to disable the default validation behavior like so: data-vv-validate-on="none"
Then add a click event handler to your submit button a @click="submit"
.
And the submit
method for your ponent would look something like this:
methods: {
submit() {
this.$validator.validateAll().then(success => {
// submit the value
})
}
}
If your version of vee-validate < 4, this might help
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745360006a4624313.html
评论列表(0条)