datetimepicker icon indicating copy to clipboard operation
datetimepicker copied to clipboard

Clicking outside of datetimepicker reinitializes the date, unwanted behaviour

Open josephernest opened this issue 8 years ago • 8 comments

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>

josephernest avatar Apr 22 '16 10:04 josephernest

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.

ghost avatar May 06 '16 08:05 ghost

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.

oshihirii avatar Jun 01 '16 04:06 oshihirii

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

zeeshanhive avatar Mar 30 '17 11:03 zeeshanhive

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

deepeshk79 avatar Jun 19 '17 03:06 deepeshk79

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 });

deepeshk79 avatar Jun 19 '17 03:06 deepeshk79

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

nickwilliams-eventbrite avatar Jan 28 '19 23:01 nickwilliams-eventbrite

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

srinudhulipalla avatar Apr 19 '19 10:04 srinudhulipalla

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

asaadmahmood avatar Aug 06 '20 11:08 asaadmahmood