Thuộc tính min của đối tượng Input DatetimeLocal lấy hoặc thiết lập ngày giờ cục bộ tối thiểu cho phép chọn.
Cú pháp
Lấy giá trị (chuỗi)
inputDatetimeLocalObject.min
Thiết lập giá trị
inputDatetimeLocalObject.min = "YYYY-MM-DDThh:mm:ss"
Định dạng chuỗi
| Thành phần | Mô tả |
|---|---|
| YYYY | Năm (ví dụ: 1999) |
| MM | Tháng (01-12, ví dụ: 07) |
| DD | Ngày (01-31, ví dụ: 11) |
| T | Phân tách ngày/giờ |
| hh | Giờ (00-23, ví dụ: 08) |
| mm | Phút (00-59, ví dụ: 18) |
| ss | Giây (00-59, ví dụ: 23) |
Ví dụ minh họa
Hiển thị mốc nhập tối thiểu cho trường datetime-local:
<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal min</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-min</legend>
<label for="datetimeLocalSelect">Hôm nay: <input type="datetime-local" id="datetimeLocalSelect" value="2019-05-23T12:45" min="2000-03-01T10:23"> </label>
<input type="button" onclick="getMinimum()" value="Mức tối thiểu?">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
function getMinimum() {
divDisplay.textContent = 'Mức nhập tối thiểu: ' + inputDatetimeLocal.min;
}
</script>
</body>
</html>
Kết quả
Nhấn nút để hiển thị giá trị min hiện tại của trường (2000-03-01T10:23).