The min
property sets or gets the min attribute of a number field.
The min
attribute sets the minimum value for a number field.
min |
Yes | 10.0 | Yes | Yes | Yes |
Return the min property.
var v = numberObject.min
Set the min property.
numberObject.min=number
Value | Description |
---|---|
number | Set the minimum value allowed |
A String type value representing the minimum numeric value allowed.
The following code shows how to change the minimum value.
<!DOCTYPE html>
<html>
<body>
Quantity:<!-- w w w.ja va 2 s. com-->
<input type="number" id="myNumber" min="1" max="10">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("myNumber").min = "5";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the minimum value allowed for a number field.
<!DOCTYPE html>
<html>
<body>
Quantity (between 1 and 5):<!-- w w w. j ava2s . 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").min;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: