xxxxxxxxxx
1
<template>
2
<MDBContainer class="m-5">
3
// changed, without validationEvent prop
4
<MDBInput
5
:minlength="5"
6
required
7
label="Label *"
8
invalidFeedback="Label must be at least 5 characters long"
9
validFeedback="OK!!"
10
:disabled="loading"
11
v-model="newTask.label"
12
:isValid = "isInputValid"
13
:isValidated = "isInputValidated"
14
@input="handleInput"
15
/>
16
17
<hr class="my-5"/>
18
// with validationEvent prop
19
20
<MDBInput
21
:minlength="5"
22
validationEvent="input"
23
required
24
label="Label *"
25
invalidFeedback="Label must be at least 5 characters long"
26
:disabled="loading"
27
v-model="newTask.label"
28
/>
29
30
<hr class="my-5"/>
31
// or without minlength
32
<MDBInput
33
validationEvent="input"
34
required
35
label="Label *"
36
invalidFeedback="Add a label please."
37
:disabled="loading"
38
v-model="newTask.label"
39
/>
40
</MDBContainer>
41
</template>
xxxxxxxxxx
1
<style>
2
#app {
3
font-family: Roboto, Helvetica, Arial, sans-serif;
4
}
5
</style>
xxxxxxxxxx
1
<script>
2
import { MDBInput, MDBContainer } from 'mdb-vue-ui-kit';
3
import { ref } from 'vue';
4
5
export default {
6
components: {
7
MDBInput, MDBContainer
8
},
9
setup() {
10
const input1 = ref('');
11
const loading = ref(false)
12
13
const newTask = ref({
14
label: ""
15
})
16
17
const isInputValid = ref(true)
18
const isInputValidated = ref(false)
19
20
const handleInput = (e) => {
21
isInputValidated.value = true;
22
isInputValid.value = e.target.checkValidity();
23
}
24
25
return {
26
newTask, loading, handleInput, isInputValid, isInputValidated
27
};
28
},
29
};
30
</script>
Console errors: 0