让 datePicker 工作以选择多个日期。当用户选择多个日期并关闭日历时,文本框以以下格式显示日期:
Thur Jan 03 2013 00:00:00 GMT +0000
Fri Jan 03 2013 00:00:00 GMT +0000
Sat Jan 04 2013 00:00:00 GMT +0000,
我的代码:
<script>
$("#HolidayDate").addClass('date-pick');
$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();
(
{
createButton: false,
displayClose: true,
closeOnSelect: false,
selectMultiple: true,
}
)
.bind(
'click',
function () {
$(this).dpDisplay();
this.blur();
return false;
}
)
.bind(
'dateSelected',
function (e, selectedDate, $td, state) {
console.log('You ' + (state ? '' : 'un') // wrap
+ 'selected ' + selectedDate);
}
)
.bind(
'dpClosed',
function (e, selectedDates) {
console.log('You closed the date picker and the ' // wrap
+ 'currently selected dates are:');
console.log(selectedDates);
$('#HolidayDate').val( selectedDates );
}
);
</script>
但是我希望日期显示为 dd-mm-yy。如果我使用注释掉的行
$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();
and run it as $('.date-pick').datePicker({dateFormat: 'dd-mm-yy'}).val();
文本框将以正确的格式返回日期,但现在它只允许我一次选择一个日期。
请指教?
谢谢