Javascript examples for DOM HTML Element:Input Number
The min property sets or gets the min attribute of a number field, which sets the minimum value for a number field.
Set the min property with the following Values
Value | Description |
---|---|
number | Sets the minimum value allowed |
A String, representing the minimum numeric value allowed
The following code shows how to get the minimum value allowed for a number field:
<!DOCTYPE html> <html> <body> Quantity://from www . j a v a 2s . c o m <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; document.getElementById("demo").innerHTML = x; } </script> </body> </html>