VeeBee VeeBee - 1 month ago 17
jQuery Question

JQUERY-UI: Datepicker - Disable day click event

I currently have a datepicker with month and year change set to true... but as part of my user-experience report feedbacks, they didn't like the datepicker automatically closing when they select the day because sometimes they change the date in random order of selection from month, day, and year. So if for instance, they changed the date selecting Month first, then Day, the datepicker automatically closes already with the Year left unchanged.

So I was looking for something like a datepicker with the day changer just setting values and not triggering a close event and just delegating that close event to the Done button alone when showButtonPanel is set to true.

Any ideas how I would achieve that?

Here is my code snippet:

<script type="text/javascript">
$(function() {
$('#datepicker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
yearRange: 'c-70:c+nn'
});
});



Answer

try this (I assume you are using jqueryui datepicker):

$(function() {
        $('#datepicker').datepicker({
           onSelect: function(dateText, inst) { inst.show() }
        });
    });