-2
我有一些在check in和check out日期使用的datepicker。我想限制每年12月31日之前的入住日期,並且不能在明年1月1日前顯示。在退房日期,它只在明年1月1日顯示。例如,我可以在2016年12月31日辦理入住手續,但我可以在2017年1月1日前退房,但不能在2017年1月2日。在datepicker中重設日期
我試過這樣的代碼但不工作。
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="bootstrap.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="bootstrap.js"></script>
</head>
<body>
<p>Check In : <input type="text" id="datepicker-13"></p><br>
<p>Check Out : <input type="text" id="datepicker-14">
</body>
<script>
$(document).ready(function() {
var today = new Date();
var lastDate = new Date(today.getFullYear(), 11, 31);
$('#datepicker-13').datepicker({
maxDate: lastDate
});
});
$(document).ready(function() {
var today = new Date();
var lastDate = new Date(today.getFullYear(), 11, 32);
$('#datepicker-14').datepicker({
maxDate: lastDate
});
});
</script>
</html>
謝謝。
您是否閱讀過文檔,特別是關於'minDate'和'maxDate'設置的部分 – adeneo
是的,我讀過,但我不明白。 @adeneo – Nicholas
你使用jQuery datepicker嗎? – Ronald