Javascript examples for DOM HTML Element:Input Number
The max property sets or gets the max attribute of a number field, which sets the maximum value for a number field.
Set the max property with the following Values
Value | Description |
---|---|
number | Sets the maximum value allowed |
A String, representing the maximum numeric value allowed
The following code shows how to get the maximum value allowed for a number field:
<!DOCTYPE html> <html> <body> Quantity:// w w w . j av a 2 s . c o m <input type="number" id="myNumber" min="1" max="5"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myNumber").max; document.getElementById("demo").innerHTML = x; } </script> </body> </html>