I have a input and I need to show : 01 02 03 04 05 06 07 08 09
But default is this: 1 2 3 4 5 6 7 8 9
<!DOCTYPE html>
<html>
<body>
<input type="number" name="quantity" min="1" max="5">
</body>
</html>
I have a input and I need to show : 01 02 03 04 05 06 07 08 09
But default is this: 1 2 3 4 5 6 7 8 9
<!DOCTYPE html>
<html>
<body>
<input type="number" name="quantity" min="1" max="5">
</body>
</html>
There is no native way of doing this, but you could listen to the input event on the text box, and pad the leading '0' every time the value changes.
var input = document.getElementById("txtNum");
input.addEventListener("input", function(e) {
e.target.value = e.target.value.padStart(2,'0');
});
<!DOCTYPE html>
<html>
<body>
<input id="txtNum" type="number" name="quantity" min="1" max="5">
</body>
</html>