6

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.

2
  • 2
    My guess would be that you can't. It's not visible markup, can't add an event to it, and just clicking the input doesn't cause it. And you can't move the mouse pointer with JS, no API for it, not that I know of. Commented Jun 17, 2015 at 7:39
  • When is it useful to be able to do this? What is the use case? Commented Jan 4, 2022 at 13:57

1 Answer 1

0

I figured it out.

The trick is to send F4 keyboard event.

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

Sign up to request clarification or add additional context in comments.

3 Comments

Coo, that works in Chrome. But it seem this is not the standard war that works everywhere?
I wonder why it doesn't work on mine. Tried triggering keyCode 115(F4) to an element but nothing happens.
Won't work ... check MDN (or comments on the linked answer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.