Please help, how to make input like this in javascript? Minimum number that can be entered = 0.01 Maximum number that can be entered = 94.99 if it passes the minimum/maximum it will automatically return to the default number for the minimum/maximum. Meanwhile, if you enter the number 01.21, the number will automatically change to 1.21
Thanks for taking the time to answer, and provide direction.
I want to create an input field similar to this
I tried like this but it doesn't work
function minmax(value, min, max) {
if (parseInt(value) < 0.01 || isNaN(value))
return 0.01;
else if (parseInt(value) > 94.99)
return 94.99;
else return value;
}
<input type="text" name="textWeight" id="txtWeight" maxlength="5" onkeyup="this.value = minmax(this.value, 0.01, 94.99)" />