I'm trying this min max input type number but it doesn't work when the user manually type. So I just disabling the button I have. Is there's another way to do it without disabling the button like I did?
const ck = document.getElementById('btn');
var inp = document.getElementById('inp');
ck.addEventListener('click', function (){
alert(inp.value);
})
inp.addEventListener('keyup', function (){
var att = this.getAttribute("max");
var vl = this.value;
if (vl > att){
ck.disabled = true;
}else{
ck.disabled = false;
}
})
<input type="number" id="inp" min="1" max="5" value="1"/>
<button id="btn">Button</button>