1

I am using JqueryUI datepicker, and I cannot call 'setDate' method on a datepicker if I use a format like this: 'mm yy'.

See my snippet here:

$(function(){
    $('#datepicker').datepicker(
        {dateFormat: 'mm yy'}
    );

    $('#datepicker').datepicker('setDate', new Date(2010, 10, 1));
    var d = $("#datepicker" ).datepicker('getDate');
    alert(d); //this should alert 2010,10,1, but it is not! it alerts the current time instead
});

http://jsfiddle.net/wintlu/DmmQU/

My observation is that: if I use format including day part, like 'dd mm yy', then i can use setDate, but if I use format without day part, like 'mm yy', then i cannot use setDate.

My question is : Is this a bug of datepicker? If so, what is the walk around ?

Thanks in advance

Wint
  • 2,268
  • 2
  • 22
  • 32
  • You need a valid date in order to use datepicker – Dom Feb 25 '13 at 23:20
  • Do you mean 'mm yy' is an invalid format? but i only need to show year and month, do you have walk around? – Wint Feb 26 '13 at 00:25
  • I don't understand... then why would you use a datepicker if you are not using the day? – Dom Feb 26 '13 at 00:42
  • i have similar requirement as this: http://stackoverflow.com/questions/2208480/jquery-ui-datepicker-to-show-month-year-only?lq=1 .I don't need the day, but I need month and year selection. Thank you very much – Wint Feb 26 '13 at 01:06

0 Answers0