I using javascript to check the length of height input by the user and but the problem I am facing is that even javascript just check the first number of the input and throws an error. Just for eexample if I have to input 45 in the height, I get an error height must be between 6-36 just after entering 4 it doesnt let me enter 5 and when i try to remove move and it input becomes empty It again throws an error height must be between 6-36. Please help me find the problem.
<input type="number" id="message1" name="height" oninput="function_two()">
function function_two() {
var FrameHeight = document.getElementsByName('height')[0].value;
if (FrameHeight <= 36 && FrameHeight >= 6)
return true;
else
alert("Height must be between 6-36");
}
onchange, or a form and a submit event listener. But please, please, please don't use inline event attributes. They are the devil.onblurevent instead ofoninput. That will wait until the input loses focus. (Oronchangelike Tiny Giant said... that will wait until the input is changed and loses focus which is probably better...)