xdan / datetimepicker

jQuery Plugin Date and Time Picker
https://xdsoft.net/jqplugins/datetimepicker/
MIT License
3.5k stars 1.51k forks source link

Clicking outside of datetimepicker reinitializes the date, unwanted behaviour #436

Open josephernest opened 8 years ago

josephernest commented 8 years ago

Try this (live demo here): Clicking outside of datetimepicker reinitializes the date to Sunday 31 December 1899. How to solve this?

<link rel="stylesheet" type="text/css" href="http://gget.it/ov1nuzeh/jquery.datetimepicker.css"/>
<input id="when" type="text"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://gget.it/dzxqdkh2/jquery.datetimepicker.full.min.js"></script>
<script>
$('#when').datetimepicker({dayOfWeekStart : 1, format:"l d F, H:i"});
</script>
ghost commented 8 years ago

HI, i had the same issues, as is wanted to get YYMMDD-HHMM output. I set

validateOnBlur: false

and now the text stays the same after clicking otuside the input box.

Hope this helps, at least it works for me.

then it works for me.

oshihirii commented 8 years ago

I also had this issue and it was resolved by implementing @skainz solution.

My code was:

$(document).ready(function() {
$('#date_and_time').datetimepicker({
format:'d / m / y  @  g:i A', 
formatTime: 'g:i A',
theme: 'dark',
validateOnBlur: false
});
});  

UPDATE:

Hmm, unfortunately, when clicking on the input again to trigger the calendar, I can see that the calendar has reset to a different month, date and year.

For example, if I initially select 01 / 06 / 16 @ 2:35 PM, then click outside of the input, then click inside the input again, the calendar pops up with this month and year selected:

31 / 12 / 99 @ 6:00 AM

Any ideas?

jquery-2.2.4.min.js

UPDATE 2:

Error doesn't occur when using jQuery DateTimePicker plugin v2.4.1, and validateOnBlur: false is not required.

zeeshanhive commented 7 years ago

@oshihirii did you reslove the error because i am still facing this error

deepeshk79 commented 7 years ago

Is this issue resolved ? I'm still facing the same error...

deepeshk79 commented 7 years ago

Got the solution, check the link [https://github.com/uxsolutions/bootstrap-datepicker/issues/1291]

The way I solved is as below i.e. using forceParse:false $('.date-time-picker').datetimepicker({ format: 'yyyy-mm-dd hh:ii', forceParse: false });

nickwilliams-eventbrite commented 5 years ago

I was also having this issue with latest versions, and I was able to solve it with validateOnBlue: false.

srinudhulipalla commented 5 years ago

I was having the same issue and fixed the same using validateOnBlur: false

asaadmahmood commented 4 years ago

I can still see the issue even with validateOnBlur: false.