How can I convert my jQuery datepicker to only accept months and years?
How can I convert my jQuery datepicker to only accept months and years?
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 .
I know a little bit about your question ... but I use the following plugin:
See if this is what you need. I have nothing to complain about him ... except he is very smart!