I am looking to create a custom datepicker
<input type="text" name="Birth" id="calendarInput" required class="inputField" placeholder="31.12.2001">
<input type="date" name="Birth" id="calendarHiddenInput" pattern="\d{4}-\d{2}-\d{2}" style="display: none">
<img id="calendarImg" src="images/calendarIcon.png">
By default, input[type=date]
provides a clickable calendar icon for selecting dates. I want to implement a similar functionality with an event listener:
$('#calendarImg').click(function () {
$('#calendarHiddenInput').click();
});
Unfortunately, the function above is not functioning as expected. My goal is to have a regular input[type=text]
with a small calendar icon that displays a datepicker like the input[type=date]
when clicked.
P.S. Once implemented, I intend to extract the value from calendarHiddenInput
and insert it into calendarInput