Skip to content Skip to sidebar Skip to footer

Datetimepicker Sets Date To Todays Date On When Clicking Outside

I have searched high and low for the answer to this issue, but no luck so now I have to ask... I have the datetimepicker from Trent Richardson, and for some reason with very minima

Solution 1:

i searched high and low too, but after putting a few debug messages, the answer was obvious. What I noticed is that the onClose method has a "value" parameter which has the actual date which you select OR if you select nothing, it has the original value from your textbox. Set it as the value of the inputbox and walaaaa! problem solved.

If you don't do this, the current date will replace your original date when you just want to close the datetimepicker.

$('input.datetime').datetimepicker({
        ampm: true,
        timeFormat: 'hh:mm tt',
        addSliderAccess: true,
        sliderAccessArgs: { touchonly: false },
        onClose: function (value) {
                        $('input.datetime').val(value);
                    }
     });

Post a Comment for "Datetimepicker Sets Date To Todays Date On When Clicking Outside"