Input Number max Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Number

Description

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

Return Value

A String, representing the maximum numeric value allowed

The following code shows how to get the maximum value allowed for a number field:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials