1
我有四種不同的日期選擇器,它們都工作,但在Date1/Date2上我可以選擇月/日/年,它只輸出月/年。如何使用完整的dateformat顯示特定的日期選擇器?
我怎樣才能讓這兩個datepicker顯示日期如mm/dd/yyyy?
https://jsfiddle.net/km96dgsd/
$(function() {
$('.date-picker').datepicker(
{ yearRange: "1980:",
dateFormat: "mm/yy",
changeMonth: true,
changeYear: true,
showButtonPanel: true,
onClose: function(dateText, inst) {
function isDonePressed(){ return ($('#ui-datepicker-div').html().indexOf('ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all ui-state-hover') > -1);
}
if (isDonePressed()){
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1)).trigger('change');
$('.date-picker').focusout()//Added to remove focus from datepicker input box on selecting date
}
},
beforeShow : function(input, inst) {
inst.dpDiv.addClass('month_year_datepicker')
if ($(input).is("#startDate2") || $(input).is("#startDate4")) {
inst.dpDiv.addClass("hide-calendar");
}
else {
inst.dpDiv.removeClass("hide-calendar");
}
}
})
});
但日期2/Date4是從日期1/DATE3不同 –
然後我不明白你的問題,你究竟在做什麼。你說你需要不同的格式1和2與3和4 – charlietfl
以及date1/date2我想dateformat mm/dd/yyyy和date3/date4格式mm/yyyy –