Ensuring a Value Is Within Bounds
Description
You use the min
and max
attributes to ensure that numeric
and date values are within a specific range.
You need not apply both attributes.
The min
and max
values are inclusive,
meaning that if you specify a max value of 100,
then any value up to and including 100 is allowed.
Example
The following code shows these attributes applied to the number type of the input element.
<!DOCTYPE HTML>
<html>
<body>
<form method="post" action="http://example.com/form">
<p>
<label for="price"> $ per unit in your area: <input
type="number" min="0" max="100" value="1" id="price" name="price" />
</label>
</p><!--from w w w. jav a2 s. c o m-->
<input type="submit" value="Submit" />
</form>
</body>
</html>