Is there a way to handle "datetime-selection" event with <input type='datetime-local'>
control?
onchange, onselect and oninput does not work for me.
The <input type="datetime-local"> defines a date picker. The resulting value includes the year, month, day, and time.
The difference between the two is that the datetime-local input does not include the time zone. If the time zone is not important to your application, use datetime-local. Some browsers are still trying to catch up to the datetime input type.
(In chrome) the onchange event triggers when the field is completely filled
Also have a read of Why is HTML5 input type datetime removed from browsers already supporting it?
Since onchange
does not occur until after the field is fully filled in I ended up doing an onselect
that sends new Date()
to the onchange
handler if the field does not yet have a value. This eliminates the false sense of a value being set (perhaps on a backing object) on the field before the time part of dateime-local is set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With