Javascript DOM HTML Input Number min Property set

Introduction

Change the minimum value:

document.getElementById("myNumber").min = "5";

Click the button to change the value of the min attribute of the number field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Quantity:/*from w w w .  j a va2  s . com*/
<input type="number" id="myNumber" min="1" max="10">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myNumber").min = "5";
  document.getElementById("demo").innerHTML = "The value of the min attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related