HTML DOM 輸入日期時間 max 屬性


HTML DOM 輸入日期時間 max 屬性返回/設定輸入日期時間的 max 屬性。

語法

以下是語法 −

  • 返回字串值
inputDatetimeObject.max
  • max 設定為字串值
inputDatetimeObject.max = YYYY-MM-DDThh:mm:ssTZD

字串值

在此,“YYYY-MM-DDThh:mm:ssTZD” 可以為以下值 −

stringValue詳細資訊
YYYY它定義年份(例如:1998)
MM它定義月份(例如:05 表示五月)
DD它定義日期(例如:24)
T它是日期和時間的分隔符
hh它定義小時(例如:12)
mm它定義分鐘(例如:48)
ss它定義秒(例如:00)
TZD時區標誌符(IST 表示印度標準時間)

示例

讓我們看一個 輸入日期時間 max 屬性的示例 −

 線上演示

<!DOCTYPE html>
<html>
<head>
<title>Input Datetime Max</title>
</head>
<body>
<form>
Date & Time: <input type="datetime" id="dateTime" name="DateSelect" value="2019-12-31T23:49:59Z" max="2019-12-31T23:59:59Z">
</form>
<button onclick="getMaxDate()">Renew Insurance</button>
<div id="divDisplay"></div>
<script>
   var inputDate = document.getElementById("dateTime");
   var divDisplay = document.getElementById("divDisplay");
   divDisplay.textContent = 'Insurance Datetime: '+inputDate.max;
   function getMaxDate() {
      var oldInputDate = inputDate.max;
      inputDate.max = '2029-12-31T23:49:59Z';
      divDisplay.textContent = 'New Insurance Datetime: '+inputDate.max;
   }
</script>
</body>
</html>

輸出

這將產生以下輸出 −

在單擊 ‘Renew Insurance’ 按鈕之前 −

在單擊 ‘Renew Insurance’ 按鈕之後 −

更新於: 30-Jul-2019

116 次瀏覽

開啟您的 職業生涯

完成課程即可獲取認證

開始
廣告
© . All rights reserved.