Input Number step Property - Change the legal number intervals for a number field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

Input Number step Property - Change the legal number intervals for a number field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Number:/*from   w ww. j a va 2  s  .  c o m*/
<input type="number" id="myNumber" step="3">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.getElementById("myNumber").step = "5";
    document.getElementById("demo").innerHTML = "The value of the step attribute was changed from '3' to '5'.";
}
</script>

</body>
</html>

Related Tutorials