Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invoke date picker from date input in javascript? [duplicate]

Chrome has native date picker for <input type="date">: date picker for date input in chrome

I like it, and it's totally ok with me to have it work only in chrome.

The question is how can I invoke date picker for this input field in javascript?

Normally there is only input field until user focus it and click little black triangle to open small calendar. I want to open it from javascript.

I would like to avoid 3rd party date picker implementations if possible.

I've tried element.focus(), element.click(), etc.

like image 416
Michał Šrajer Avatar asked Nov 09 '22 11:11

Michał Šrajer


1 Answers

I figured it out.

The trick is to send F4 keyboard event.

See details in my answer for (indeed) duplicated question here

like image 193
Michał Šrajer Avatar answered Nov 14 '22 21:11

Michał Šrajer