Thuộc tính Thời gian nhập liệu tối thiểu của HTML DOM trả về / đặt thuộc tính Thời gian nhập liệu tối thiểu.
Cú pháp
Sau đây là cú pháp -
- Giá trị chuỗi trả về
inputTimeObject.min
- Đặt tối đa thành giá trị chuỗi
inputTimeObject.min = hh:mm:ss.ms
Giá trị chuỗi
Đây, “hh:mm:ss.ms” có thể như sau -
| stringValue | Chi tiết |
|---|---|
| hh | Nó xác định giờ (ví dụ:18) |
| mm | Nó xác định phút (ví dụ:59) |
| ss | Nó xác định giây (ví dụ:00) |
| ms | Nó xác định mili giây (ví dụ:700) |
Ví dụ
Hãy để chúng tôi xem ví dụ về Thời gian nhập liệu tối thiểu tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input Time 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>Time-min</legend>
<label for="TimeSelect">Time Elapsed:
<input type="time" id="TimeSelect" value="00:00:00" min="01:30:00">
</label>
<input type="button" onclick="getElapsedTime()" value="Confirm">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputTime = document.getElementById("TimeSelect");
divDisplay.textContent = 'Minimum wait time: '+inputTime.min;
function getElapsedTime() {
if(inputTime.value >= inputTime.min)
divDisplay.textContent = 'You can leave exam hall now, as you have waited for: '+inputTime.value;
else
divDisplay.textContent = 'You cannot leave exam hall before: '+inputTime.min;
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Xác nhận’ nút -
Sau khi nhấp vào ‘Xác nhận’ nút có trường thời gian không hợp lệ -
Sau khi nhấp vào ‘Xác nhận’ nút có trường thời gian hợp lệ -