HTMLInputElement: max 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

HTMLInputElement 接口的 max 属性反映了 <input> 元素的 max 属性,该属性通常定义了数字或日期时间输入的有效最大值。如果未显式设置该属性,则 max 属性为空字符串。

一个表示元素 max 值的字符串,如果未显式设置 max,则为空字符串。

示例

js
const inputElement = document.querySelector("#time");
console.log(inputElement.max); // the current value of the max attribute
inputElement.max = "18:00:00"; // sets the max value to 6pm

规范

规范
HTML
# dom-input-max

浏览器兼容性

另见