I am working with a group of checkboxes:
<div class="options">
<input type="checkbox" value="10" v-model="choices">
<input type="checkbox" value="30" v-model="choices">
<div class="group">
<input type="checkbox" value="50" v-model="choices">
<input type="checkbox" value="70" v-model="choices">
</div>
</div>
I am storing the checked values in a data variable:
new Vue({
el: '#app',
data() {
return {
choices: [],
}
},
});
I am struggling to find a way to limit checking more than one checkbox inside the .group element. I initially considered using radio buttons, but encountered some issues, so I decided to continue with checkboxes. I believe I could achieve this using jQuery or vanilla JS, however, I am unsure about where to implement the check (on change event method?). What would be the best approach to accomplish this in VueJS?
You can view my code on CodePen here: https://codepen.io/RomkaLTU/pen/LXOJgr?editors=1010