Input Time max attribute

Definition and usage

max attribute to set or return the value of the max attribute of the time field.

HTML max attribute to specify the maximum value (time) of the time field.

Tip:Use max and min properties to create a series of valid values.

Tip:To set or return the value of the min attribute, use min attribute.

See also:

HTML reference manual:HTML <input> max 属性

Example

Example 1

Get the longest allowed time for the time field:

var x = document.getElementById("myTime").max;

Try it yourself

Example 2

Change the longest allowed time:

document.getElementById("myTime").max = "23:59";

Try it yourself

Syntax

Return max attribute:

timeObject.max

Set max attribute:

timeObject.max = hh:mm:ss.ms

Attribute value

Value Description
hh:mm:ss.ms

The longest time allowed for the specified time field.

Component description:

  • hh - Hours (e.g., 22 indicates 10 PM)
  • mm - Minutes (e.g., 30)
  • ss - Seconds (e.g., 03)
  • ms - Milliseconds (e.g., 20)

Examples: "08:39:21.33", "22:36:07" or "15:00".

Technical details

Return value: 字符串值,表示时间字段允许的最长时间。

浏览器支持

表中的数字注明了首个完全支持该属性的浏览器版本。

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 10.0 支持 支持 支持

注意:<input type="time"> 元素在 Firefox 中不显示为任何时间字段。