English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag大全

HTML: <input> max attribute

The max attribute specifies the maximum value of the <input> element, the max and min attributes are applicable to the following input types: number, range, date, datetime, datetime-local-local, month, time, and week.

 HTML <input> tag

Online Example

Demonstration of the use of min and max attributes:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> max and min attributes - Basic Tutorial Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  input1999year11month31date before today:
  <input type="date" name="bday" max="1999-11-31><br>
  input2010year1month2date after today:
  <input type="date" name="bday" min="2010-01-02><br>
  quantity(1to5between):
  <input type="number" name="quantity" min="1" max="5><br>
  <input type="go submit">
</form>
</html>
Test and see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 10Opera, 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:Due to Internet Explorer 10 These input types are not supported, the max attribute will not be applicable to IE 10 of date and time.

Definition and usage

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

Tip:The max attribute is compatible with min attributes in combination can create a valid value range.

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

HTML 4.01 with HTML5differences

The max attribute is an HTML5 of the new attributes.

Syntax

<input max="number|date">

Attribute value

ValueDescription
numberNumeric value. Specifies the maximum allowed value for the input field.
dateDate. Specifies the maximum allowed value for the input field.
 HTML <input> tag