'Console.log error when clicking an input type="date"

I'm using HTML5 and adding an input with a type="date" for a date picker, but when I have Developer Tools open, every time I click in my input I get the following error displayed.

Uncaught DOMException: Failed to set the 'selectionEnd' property on 'HTMLInputElement': The input element's type ('date') does not support selection

Although it's not causing an issue to the user, ideally I don't want the error and was wondering if anyone has come across this and how to fix it.

This is my HTML:

<input id="startDate" class="form-control text-uppercase" type="date" />

Screenshot of my console.log:

enter image description here



Solution 1:[1]

There's an answer to a related question here.

Essentially, Chrome is not currently supporting selection for inputs except the text, search, tel, url, and password types. You are triggering selectionEnd by clicking into the input; there's nothing wrong with your code.

The current suggested workaround is to set your input's type to text and use the pattern attribute to ensure valid input although that will not allow you to use the browser-provided date picker if one exists.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 D M