I am trying to add validation for input type number to accept only integer.
I added pattern="\d*"
to the element. It works fine for input 10.12
, 10.13
. But fails for input 10.
I printed the value for the html input. It is 10
instead of 10.
.
<script>
function getValue(){
alert(document.getElementById("numberInput").value);
}
</script>
<input type="number" id="numberInput"> </input>
<button onclick="getValue();">
Ideally it should consider 10.
as invalid input.