Course Recommendation:
HTML <input> max attribute
max
Definition and Usage
The attribute specifies the maximum value of the <input> element.Hint: max
The attribute associates with min attribute Used together, they can create a range of valid values.
Note:max
and min
The attribute applies to the following input types:
- number
- range
- date
- datetime-local
- month
- time
- week
Example
Use the min and max attributes:
<form action="/action_page.php"> <label for="datemax">Please enter a date before January 1, 1980:</label> <input type="date" id="datemax" name="datemax" max="1979-12-31"><br><br> <label for="datemin">Please enter a date after January 1, 2000:</label> <input type="date" id="datemin" name="datemin" min="2000-01-02"><br><br> <label for="quantity">Please enter the quantity (between 1 and 5):</label> <input type="number" id="quantity" name="quantity" min="1" max="5"><br><br> <input type="submit"> </form>
Syntax
<input max="number|date">
Attribute Value
Value | Description |
---|---|
number | Specifies the maximum allowed value. |
date | Specifies the latest allowed date. |
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
5.0 | 10.0 | 16.0 | 5.1 | 10.6 |
max
The attribute is a new attribute of the <input> tag in HTML5.