var input = document.getElementById("test");
var check = function () {
var val = +this.value;
if (typeof val === "number" && val < 0) {
this.value = 0;
}
if (typeof val === "number" && val > 60) {
this.value = 60;
}
if (isNaN(val)) {
this.value = "";
}
};
input.addEventListener("keyup", check, false);
.block {
background: #fff;
}
.color1 {
background: #000;
}
var block = document.querySelector('.block');
block.addEventListener('mouseenter', function () {
block.classList.add('color1');
});
block.addEventListener('mouseleave', function () {
block.classList.remove('color1');
});