我有以下兩個日期選擇對象,但我不能得到我想要的,因爲我陷入與的minDate和的maxDate選項:jQuery的日期選擇器MINDATE,MAXDATE
這是限制日期未來日期。
我想要什麼:限制日期從當前日期到30年時間。
我得到的結果:限制從當前日期到10年的日期。
$(".datepickerFuture").datepicker({
showOn: "button",
buttonImage: 'calendar.gif',
buttonText: 'Click to select a date',
duration:"fast",
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy',
constrainInput: true,
minDate: 0,
maxDate: '+30Y',
buttonImageOnly: true
});
這是限制只選擇過去的日期:
我想什麼:從當前的日期限制日期以120年前的時間。
我得到:限制從當前日期到120年前的時間日期,但是當我選擇了一年的最大年將恢復到選定的年份(例如什麼,我會得到從時新的一頁負荷1890- 2010年,但如果我選擇2000年的選擇框重置爲1880-2000)。
$(".datepickerPast").datepicker({
showOn: "button",
buttonImage: 'calendar.gif',
buttonText: 'Click to select a date',
duration:"fast",
changeMonth: true,
changeYear: true,
dateFormat: 'dd/mm/yy',
constrainInput: true,
yearRange: '-120:0',
maxDate: 0,
buttonImageOnly: true
});
我需要兩個datepicker對象的幫助,任何幫助將非常感激。
爲+30,那是什麼我想,但我只是+10年。 對於-120年,你是什麼意思? 謝謝。 – Amra 2010-04-14 16:06:43
我剛剛使用'-120Y'爲minDate,0爲maxDate,如果您查看jsBin鏈接,您可以看到我使用的代碼 – 2010-04-14 16:21:42
@Cesar - 年的下拉列表將根據當前年份進行更改。它似乎只顯示當前年份的-10/+ 10,但尊重您提供的最小/最大值。查看jQuery UI js文件中_generateMonthYearHeader的代碼。 – tvanfosson 2010-04-14 16:24:45