user284875
user284875

Reputation: 45

jQuery date picker to select only month and year?

I want to use jQuery date picker to select month and year only?. I tried it using date format, it working but show dates too. I am trying a way to select month and year only

Upvotes: 1

Views: 962

Answers (2)

Shezi
Shezi

Reputation: 1342

To the best of my knowledge, that's not possible. It's a date picker, you can't omit date from the output. Your best bet would be to: 1) grab the month and year using date format 2) use two separate drop down lists, one for month and one for year

Upvotes: 0

HDT
HDT

Reputation: 2047

try

$('.date-picker').datepicker( {
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'MM yy',
    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));
    }
});

Upvotes: 2

Related Questions