Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically initiate html5 datetime-local

Tags:

html

datetime

is there anyway to initiate the calendar / time view from the html5 element type="datetime-local" ?

<input type="datetime-local" id="dtl" />

<script>
$('#dtl').click();
</script>

doesn't work, even though you can listen for events on click.

like image 538
user3000116 Avatar asked Oct 02 '22 10:10

user3000116


1 Answers

Unfortunately, not really.

The HTML5 calendar view is implemented differently by each browser, so there's no solid way of activating the browser's datetime calendar picker. The best you could do is probably $('#dtl').focus(); to focus in the field, but I know that's not what you want.

A cross-browser alternative is to use something like the jQuery UI datepicker.

like image 189
robyoder Avatar answered Oct 07 '22 17:10

robyoder