HTML DOM 輸入 DatetimeLocal max 屬性
HTML DOM 輸入 DatetimeLocal max 屬性返回/設定輸入 DatetimeLocal 的 max 屬性。
語法
以下是語法 −
- 返回字串值
inputDatetimeLocalObject.max
- 將 max 設定為字串值
inputDatetimeLocalObject.max = YYYY-MM-DDThh:mm:ss
字串值
此處,“YYYY-MM-DDThh:mm:ss” 可以是以下內容 −
| 字串值 | 詳細資訊 |
|---|---|
| YYYY | 定義年份(例如:2006) |
| MM | 定義月份(例如:06 表示 6 月)。 |
| DD | 定義日期(例如:17) |
| T | 作為日期和時間的分割符 |
| hh | 定義小時(例如:02) |
| mm | 定義分鐘(例如:21) |
| ss | 定義秒(例如:40) |
示例
讓我們看一個 輸入 DatetimeLocal max 屬性的示例 −
<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal max</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Datetime-Local-max</legend>
<label for="datetimeLocalSelect">Insurance Expiration:
<input type="datetime-local" id="datetimeLocalSelect" value="2019-07-01T23:59:59" max="2019-08-01T23:59:59" disabled>
</label>
<input type="button" onclick="renewInsurance()" value="Renew Insurance">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
function renewInsurance() {
inputDatetimeLocal.max = '2029-07-01T23:59:59';
inputDatetimeLocal.value = inputDatetimeLocal.max;
divDisplay.textContent = 'Renewed Insurance: '+inputDatetimeLocal.value;
}
</script>
</body>
</html>輸出
這將產生以下輸出 −
點選‘續保’按鈕前 −

點選‘續保’按鈕後 −

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP