我正在使用jQuery datepicker從用戶請求日期輸入。我設置了本地默認值,並讓它生成我想要的正確日期格式(日/月/年)。出於某種原因,此日期以表單(mm/dd/yyyy)形式發佈 - 如何確保發佈正確的格式?jQuery datepicker發佈錯誤日期值
設置的默認值:
jQuery(function($) {
$.datepicker.regional['en-GB'] = {
monthNames: [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
],
monthNamesShort: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
],
dayNames: [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
],
dayNamesShort: [
'Sun',
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat'
],
dayNamesMin: [
'Su',
'Mo',
'Tu',
'We',
'Th',
'Fr',
'Sa'
],
dateFormat: 'dd/mm/yy',
firstDay: 1,
renderer: $.datepicker.defaultRenderer,
prevText: 'Prev',
prevStatus: 'Show the previous month',
prevJumpText: '<<',
prevJumpStatus: 'Show the previous year',
nextText: 'Next',
nextStatus: 'Show the next month',
nextJumpText: '>>',
nextJumpStatus: 'Show the next year',
currentText: 'Current',
currentStatus: 'Show the current month',
todayText: 'Today',
todayStatus: 'Show today\'s month',
clearText: 'Clear',
clearStatus: 'Erase the current date',
closeText: 'Done',
closeStatus: 'Close without change',
yearStatus: 'Show a different year',
monthStatus: 'Show a different month',
weekText: 'Wk',
weekStatus: 'Week of the year',
dayStatus: 'Select DD, M d',
defaultStatus: 'Select a date',
isRTL: false
};
$.datepicker.setDefaults($.datepicker.regional['en-GB']);
});
正開始的日期選擇器
$(".datepicker").each(function() {
$(this).datepicker({
onSelect: onSelectHandler
});
});
向我們展示一些代碼。很難猜測你做錯了什麼。 – Iznogood 2012-02-23 16:25:22