0

By default, the datepicker opens when the icon is clicked.

Now, i want the datepicker to appear when the input field is clicked. I can achieve this by enlarging the icon to 100% width, but i can't make it transparent, so there would be no icon at all but only the text visible...

I think i have seen solutions fro this the other day, but now, i did not find anything at all.

How can i get the desired effect? PS: A onFocus solution would be even better than onClick.

input#modified::-webkit-calendar-picker-indicator {
  width: 100%;
  margin: 0;
  border: 1px solid red;
  background: none;
}
Normal: only icon-click shows datepicker 
<input type="datetime-local" ><br>
Modified: click red outline for datepicker
<input type="datetime-local" id="modified">

2
  • 1
    Does this answer your question? Method to show native datepicker in Chrome Commented Nov 3, 2021 at 14:05
  • Yes, it is the Page I had seen before. The answer I used is linked in the answer below. Commented Nov 4, 2021 at 22:49

2 Answers 2

2

This works for me. It is the answer that i had seen before but did not find.

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

1 Comment

Check this link out stackoverflow.com/a/70578150/2625761 which uses the onfocus event and the browser's showPicker method.
1

Here's how i did it in React (Yes i did use showPicker() but it is used like e.currentTarget.showPicker()):

<input
    type="date"
    className="form-control"
    onClick={(e) => e.currentTarget.showPicker() }
/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.