HTML <input> maxAttribute

HTML input 标签参考手册HTML <input> Tag

Example

Usage of the min and max attributes:

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

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Opera, Chrome, and Safari support the max attribute.

Note:Firefox or Internet Explorer 9 and earlier versions do not support the max attribute of the <input> tag.

Note:Since Internet Explorer 10 does not support these input types, the max attribute will not apply to date and time in IE 10.


Definition and Usage

The max attribute specifies the maximum value for an <input> element.

Tip:The max attribute, when used together with theminattribute, can create a range of legal values.

Note:The max and min attributes apply to the following input types: number, range, date, datetime, datetime-local, month, time, and week.


Differences between HTML 4.01 and HTML5

The max attribute is a new attribute in HTML5.


Syntax

<input max="number|date">

Attribute Values

Value Description
number Number. Specifies the maximum value allowed for the input field.
date Date. Specifies the maximum value allowed for the input field.


HTML input 标签参考手册HTML <input> Tag Other Extensions