Datetimepicker sets date to today when clicked outside

I searched high and low for an answer to this question, but no luck, now I have to ask ...

I have a datetimepicker from Trent Richardson, and for some reason with very minimal parameters, it automatically sets the date field to today's date when I find out without selecting a date.

Anyone have an idea what is going on?

This is my code:

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

Appreciate all the help I can get, which causes some confusion for my employees using the app ...

+1
source share
1 answer

I also searched high and low, but after entering a few debugging messages, the answer was obvious. I noticed that the onClose method has a "value" parameter that has the actual date that you select OR, if you did not select anything, it has the original value from your text box. Set it as the value of the input field and walaaaa! the problem is resolved.

If you do not, the current date will replace the 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); } }); 
0
source

All Articles