Can you change the background color of the initial
input field to green if the value of the Fullname
input field is greater than 3 characters?
See below for the code:
<div id="app">
<input type="text" v-model="fullname" placeholder="Enter Full Name" @input="changeInitialColor"/>
<input type="text" v-model="initial" placeholder="On Full Name make it green"/>
</div>
Please find the JavaScript code snippet:
new Vue({
el: "#app",
data: {
fullname:'',
inital:''
},
methods: {
changeInitialColor(){
if(this.fullname.length > 3){
console.log('Change v-model=Initial field color into green');
}
else{
console.log("Dont change color");
}
}
}
})
You can also access the code on JSFIDDLE
: