password: '',
confirmPassword: '',
computed: {
empty() {
return this.user.password === '' || this.user.confirmPassword === '';
},
equal() {
return this.user.password === this.user.confirmPassword;
}
}
.empty {
width: 160px;
height: 50px;
line-height: 50px;
text-align: center;
font-size: 16px;
font-weight: 600;
color: #fff;
background-color: #f68e91;
border-radius: 10px;
margin-top: 15px;
padding: 0 20px;
cursor: pointer;
opacity: 0.5;
display: flex;
justify-content: center;
align-items: center;
outline: none;
border: none;
}
.no-empty {
opacity: 1.5;
background-color: #ee1d24;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<input v-model="user.password" type="text">
<input v-model="user.confirmPassword" type="text">
<button :class="[empty ? 'empty' : 'no-empty']" :disabled="empty">Send</button>
</div>
For the above code, i am able to change color of button if fields are empty, and if filled are not empty changing color.
But issue is in the confirmPassword field if i enter single character only it is changing color of button.I need as if password and confirm password is match only change button color, else different color.