datetimepicker
datetimepicker copied to clipboard
Disable default date and time on page load
Hi, I'd like to know how to prevent the datetimepicker from setting the value to current date/time. When the page first loads and the input is empty but not clicked yet, calling $("#datetimepicker1").datetimepicker('getValue');
returns the current time instead of null. I have tried setting defaultSelect to false.
Would also like to get a way to fix this.
$("#datetimepicker1").datetimepicker('getValue');
should return null
when the input is empty. Returning the current date is wrong, IMO.
Also tried defaultDate: null
, which does not work as well.
Try setting the initTime
and defaultSelect
values to false.
I believe the first one should say whether the time provided in your field value is used as init time, and the second one should say whether it should be used as default value, but I don't think it's implemented very well because getCurrentValue() will set the value from your field regardless of the initTime setting.
Has anyone found a solution?
Try setting the
initTime
anddefaultSelect
values to false.I believe the first one should say whether the time provided in your field value is used as init time, and the second one should say whether it should be used as default value, but I don't think it's implemented very well because getCurrentValue() will set the value from your field regardless of the initTime setting.
I tested this and it doesn't work. It only returns null if you click on the datetimepicker and delete the contents of the field. What I'm doing to validate that the field is null, is to check the field's val() and compare it with empty and/or with the mask I used.