假設你使用jQuery UI的datepicker,我認爲你正在尋找日期範圍。你有這樣的標記:
<label for="from">From</label>
<input type="text" id="from" name="from" />
<label for="to">to</label>
<input type="text" id="to" name="to" />
然後,在JS,
$(function() {
$("#from").datepicker({
//not needed
defaultDate: "+1w",
//to show the month dropdown
changeMonth: true,
//the number of months to be shown when input is focussed
numberOfMonths: 1,
//**Important!**
onClose: function(selectedDate) {
//dynamically set min-date of second datepicker to selected date in the first datepicker
$("#to").datepicker("option", "minDate", selectedDate);
}
});
$("#to").datepicker({
defaultDate: "+1w",
changeMonth: true,
numberOfMonths: 1,
onClose: function(selectedDate) {
//dynamically set max-date property of #from text box
$("#from").datepicker("option", "maxDate", selectedDate);
}
});
});
文檔:http://jqueryui.com/datepicker/#date-range
[jQuery的日期選擇器設置MINDATE]的
可能重複(HTTP://計算器.COM /問題/ 16368534/jQuery的日期選擇器,設置MINDATE) – adeneo