Thuộc tính tối đa của Tuần nhập DOM HTML trả về / đặt thuộc tính tối đa của Tuần nhập.
Cú pháp
Sau đây là cú pháp -
- Giá trị chuỗi trả về
inputWeekObject.max
- Đặt tối đa thành giá trị chuỗi
inputWeekObject.max = YYYY-Www
Giá trị chuỗi
Đây, “YYYY-Www” có thể như sau -
| stringValue | Chi tiết |
|---|---|
| YYYY | Nó xác định năm (ví dụ:2017) |
| W | Đây là dấu phân cách giữa năm và tuần |
| ww | Nó xác định tuần (ví dụ:52) |
Ví dụ
Hãy để chúng tôi xem một ví dụ về Mức tối đa của Tuần nhập tài sản -
<!DOCTYPE html>
<html>
<head>
<title>Input Week 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>Week-max</legend>
<label for="WeekSelect">Ongoing Week:
<input type="week" id="WeekSelect" value="2020-W01" max="2019-W52" disabled>
</label>
<input type="button" onclick="renewInsurance()" value="Renew Insurance">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputWeek = document.getElementById("WeekSelect");
divDisplay.textContent = 'Insurance Expired as of: Week'+inputWeek.max.split("-W")[1];
divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
function renewInsurance() {
inputWeek.max = '2029-W52';
divDisplay.textContent = 'Insurance Renewed till: Week'+inputWeek.max.split("-W")[1];
divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
}
</script>
</body>
</html> Đầu ra
Điều này sẽ tạo ra kết quả sau -
Trước khi nhấp vào ‘Gia hạn bảo hiểm’ nút -
Sau khi nhấp vào ‘Gia hạn bảo hiểm’ nút -