I don't think that yy-mm
and yy-mm-dd
has any conflicts.I tried the same check this Fiddle.Both the file formats are on same page
How to use different date formats for different date inputs in jquery
-
17-07-2023 - |
Question
I am trying to use multiple date inputs on same page, some must have format yy-mm-dd
and others format yy-mm
. When I added jquery code for yy-mm
format the input with yy-mm-dd
format lost dates, only months and years are visible?
$(function() {
var currentDate = new Date();
$( ".datepicker" ).datepicker({ dateFormat: "yy-mm-dd" });
$( ".datepicker" ).datepicker( "setDate",currentDate );
});
$(function() {
$('.month-picker').datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: true,
dateFormat: 'yy-mm',
onClose: function(dateText, inst) {
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));
}
});
});
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow