HTML behavior for input type "date" and "time" on Safari

Hello,

I'm working for an IT company which edit Web apps and we use HTML tags <input /> with type="date" and type="time". Actually, we've got different problems on Safari (what I read was that these problems appeared with Safari 16).

For <input type="date"/> and <input type="time"/>, the User Agent of Safari create <div> tags inside <input/> tags (with pseudo-class "-webkit-datetime-edit-day-field" for instance) to display "ghost"/faked data when the <input/> value is empty or NULL (in fact, Safari display the current date, in the local format, in <input type="date"/>). This behavior is really problematical for us because these inputs don't have to be filled every time (they are not required and don't have the attribute "required"), but they appear filled to our users... When you submit the form, the value is really empty (no value returned and that is what we want) but "something" is always displayed. We found a CSS trick to hide these things to our users but I think it's not normal, isn't it ? Can we block this Safari behavior ?

Second problem : for <input type="time"/>, they are not editable anymore if their value is empty (we detect it thursday, April 6th 2023). However, if we put a specific value when we load the page, then we delete this value in the form, and then we change the value without loosing the focus of the input, it works. If we loose the focus, we can't click on the input to change its value or something else. Do you know the reason why ? For now, we are forced to change the type of these inputs to type="text" when users are on Safari in Javascript... Nevertheless, the official documentation (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date and https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time) talks about compatibility between <input type="time"/> and Safari. Any idea ?

Thank you for your time.

Post not yet marked as solved Up vote post of CM-PM Down vote post of CM-PM
3.4k views

Replies

This is still an issue. Has there been an update on this behavior?

  • There is no update about this behavior and I still have no answer... (I'm using Safari on Mac - Version 16.5 (18615.2.9.11.4))

Add a Comment