Get the maximum value allowed for a number field:
var x = document.getElementById("myNumber").max;
Click the button to display the value of the max attribute of the number field.
<!DOCTYPE html> <html> <body> Quantity (between 1 and 5)://from www .jav a2 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>
The max
property sets or gets the value of the max attribute of a number field.
The max attribute specifies the maximum value for a number field.
The max
property accepts and returns a number type value.