window.onload = function init() {
console.log("DOM is ready!");
var input, value;
input = document.getElementById("yourGuess");
input = input.value;
input.addEventListener("checking", check, false);
check(value);
}
function check(value) {
if(input < 0 && input > 10) {
alert("The number must be between 0 - 10");
value = 0;
}
}
<label for="yourGuess">You choose: </label>
<input id="yourGuess" type="number" min="0" max="10">
I can't find any solution anywhere that correspond to the issue above.
So I have a number type input and declared a min and max attribute with the value 0 and 10 respectively.
The user can click the input field and change its value outside of range, hence I need to use javasricpt to check any changes made
input = input.value;Due to this, next line will throw error