I have a problem with datetime-local picker in HTML5. I want to clear the datetime with the clear button, but this is not possible because the "required" function inside the input will not allow. I will let a piece of code to see the differences. One is with required and one without required. Do you know how to keep the "required" and also clear the input from ex: "15/03/2022 00:00 AM" to mm/dd/yyyy --:-- --. Thank you.
label {
display: block;
font: 1rem 'Fira Sans', sans-serif;
}
input,
label {
margin: .4rem 0;
}
<input type="datetime-local" name="start_timestamp" id="start_timestamp" required>
<label for="meeting-time">Choose a time for your appointment:</label>
<input type="datetime-local" id="meeting-time"
name="meeting-time">
I'm afraid it's not possible.
According to the documentation :
On Chrome the clear button is inside a popover and does nothing if the field is
required. But on Firefox (following screenshot) the clear button is inside theinputand is not shown if the field isrequired.You should add your own clear button next to each
input: