How to make Jquery datepicker accept only months and year?

3

How can I convert my jQuery datepicker to only accept months and years?

    
asked by anonymous 12.09.2015 / 23:29

2 answers

3

For this jQuery datepicker you can do a hack that works as follows:

Add none in the CSS class of days as below:

.ui-datepicker-calendar {
    display: none;
}

Soon after you set your datepicker like this:

$('.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));
        }
    });

Follow the jsfiddle .

    
12.09.2015 / 23:35
2

I know a little bit about your question ... but I use the following plugin:

link

See if this is what you need. I have nothing to complain about him ... except he is very smart!

    
12.09.2015 / 23:49