tempusdominus / bootstrap-4

Tempus Dominus Bootstrap 4 Datetime Picker
https://getdatepicker.com/5-4/
MIT License
611 stars 239 forks source link

Bug after you enter alpha chars #318

Closed invaders-xx closed 4 years ago

invaders-xx commented 4 years ago

if you select a date using the selector and then replace the date by alpha characters in the input field (i.e. : abcde), then it shows this error on console: TypeError: this._dates[b] is undefined

and the picker is not working anymore.

Many thanks for your feedback.

ouija commented 4 years ago

You either need to utilize a masking plugin on the input (to force date input in the format defined for the datepicker) OR you need to completly disable any manual input on the datepicker field by adding a "readonly" attribute to it (which is my preferred method to use, as this also disables on-screen keyboards from appearing when viewing on mobile devices)

invaders-xx commented 4 years ago

Hello, I tried to add readonly attribute, but unable to select the date : everything is disable. If you have a working example, it would be very appreciated. BR David

ouija commented 4 years ago

My apologies, I forgot that when the readonly attribute is defined on the field, you need to define the option of ignoreReadonly: true for the .datetimepicker() initalization:

$('#dateField').datetimepicker({ ignoreReadonly: true });

Hope this helps!

invaders-xx commented 4 years ago

Works fine! Many thanks.