Answer the question
In order to leave comments, you need to log in
How to properly validate a Vue form?
I need to do form validation.
1. When creating a task, at least 10 characters. Red border.
2. If correct, it was green
3. And that the button would not be active until the correct value is entered.
jsfiddle code here
Answer the question
In order to leave comments, you need to log in
computed: {
newTodoValid() {
return this.newTodo.length >= 10;
},
},
<input :class="newTodoValid ? 'valid' : 'not-valid'">
<button :disabled="!newTodoValid">
.valid {
border: 2px solid green;
}
.not-valid {
border: 2px solid red;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question