开始日期:用户可以选择开始日期为6个月。例如:如果今天是2010年4月23日,那么我可以回到2009年11月23日但不超过6个月。jquery datepicker:选择日期为6个月
<script type="text/javascript">
$(document).ready(function() {
$('#endDate').datepicker({ showOn: 'button',
buttonImage: '../images/Calendar.png',
buttonImageOnly: true, onSelect: function() { },
onClose: function() { $(this).focus(); }
});
$('#startDate').datepicker({ showOn: 'button',
buttonImage: '../images/Calendar.png',
buttonImageOnly: true, onSelect:
function (dateText, inst) {
$('#endDate').datepicker("option", 'minDate', new Date(dateText));
}
,
onClose: function() { $(this).focus(); }
});
});
更新代码:
var currentDate = new Date();
var currentMonth = currentDate.getMonth() + 1;
var sixMonths = currentMonth + 6
currentDate.setMonth(currentDate.currentMonth, sixMonths);
var myNewCurrentDate = new Date(currentDate)
$('#startDate').datepicker('option', { minDate: myNewCurrentDate });
我得到的currentdate = NaN的
谢谢尼克.... – 2010-04-24 01:39:29