Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where did the clear button go on date type input elements in Chrome?

Up until last Thursday the date type input elements used to have a clear button (a cross or "x") next to them.

Now it looks like this:

enter image description here

Does anyone know what has changed? How can I get the clear button back?

We are using angular and Chrome as the browser.

The HTML code below shows the problem (when Chrome is used):

<label for="birthdaytime">Birthday (date and time):</label> <input type="datetime-local" id="birthdaytime" name="birthdaytime">
like image 799
Ian Hannah Avatar asked Jun 01 '20 15:06

Ian Hannah


People also ask

How do you reset input date?

$('input[type=date]'). val(''); $('input[type=date]'). val('0000-00-00');

How do you clear a field in Javascript?

To clear an input field after submitting:Add a click event listener to a button. When the button is clicked, set the input field's value to an empty string. Setting the field's value to an empty string resets the input.


1 Answers

It was reported as a bug:

https://bugs.chromium.org/p/chromium/issues/detail?id=1087490#c1

https://bugs.chromium.org/p/chromium/issues/detail?id=1087501

And someone in the bug discussion suggested a workaround: add a button that will clear the date-local element value:

<input id=el type=datetime-local value="2025-07-01T12:44">
<button onclick="javascript:el.value=''">X</button>

https://jsfiddle.net/cxpt4r8b/

like image 193
gearcoded Avatar answered Oct 12 '22 03:10

gearcoded