How can I disable month selection in the jQuery datepicker?
You can effectively disable them using stepMonths
by making them go nowhere when clicked, like this:
$("#date").datepicker({
changeMonth: false,
changeYear: false,
dateFormat: 'dd/mm/yy',
duration: 'fast',
stepMonths: 0
});
You can give it a try here
Or, you could remove the buttons like this:
$("#date").datepicker({
changeMonth: false,
changeYear: false,
dateFormat: 'dd/mm/yy',
duration: 'fast'
}).focus(function() {
$(".ui-datepicker-prev, .ui-datepicker-next").remove();
});
You can give that a try here, this works because the default showOn
option is focus
, if you're using a different event, just bind to that after the .datepicker()
call (so its event runs first, you can't hide what isn't created yet).
The mentioned solution did not work for me, I developped this:
$('#datepicker').find('.ui-datepicker-next').remove();
$('#datepicker').find('.ui-datepicker-prev').remove();