HTML input max attributes
Examples
min and max attributes to use:
<form action="demo_form.html">
Enter a date before 1980-01-01:
<input type="date" name="bday" max="1979-12-31">
Enter a date after 2000-01-01:
<input type="date" name="bday" min="2000-01-02">
Quantity (between 1 and 5):
<input type="number" name="quantity" min="1" max="5">
<input type="submit">
</form>
Enter a date before 1980-01-01:
<input type="date" name="bday" max="1979-12-31">
Enter a date after 2000-01-01:
<input type="date" name="bday" min="2000-01-02">
Quantity (between 1 and 5):
<input type="number" name="quantity" min="1" max="5">
<input type="submit">
</form>
try it"
Browser Support
Internet Explorer 10, Opera, Chrome and Safari support max attributes.
Note: Firefox or Internet Explorer 9 and earlier versions do not support the max attribute <input> tag.
Note: Because Internet Explorer 10 does not support these types of input, max attribute IE 10 will not apply to the date and time.
Definition and Usage
max attribute specifies the maximum value of <input> elements.
Tip: max property min property used in conjunction to create a range of legal values.
Note: max and min attributes apply to the following types of input: number, range, date, datetime , datetime-local, month, time and week.
Differences between HTML 4.01 and HTML5
max attribute is new in HTML5 attributes.
grammar
<input max="number|date">
Property Value
值 | 描述 |
---|---|
number | 数字值。规定输入字段允许的最大值。 |
date | 日期。规定输入字段允许的最大值。 |
HTML <input> tag