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

瀏覽器相容性

另見