<button class="year" name="date">
Year
</button>
<button class="mouth" name="date">
Mouth
</button>
<button class="day" name="date">
Day
</button>
let buttons = document.getElementsByName("date");
for(let btn of buttons) {
btn.addEventListener("click", function(e) {
e.target.dataset.ready = true;
let isReady = true;
for(let btn of buttons) {
if(!btn.dataset.ready) {
isReady = false;
}
}
if(isReady) {
console.log("Сюда можете вставить ваш код");
}
});
}