I am using html input element with type as date,
<input type="date">
When I use above element it creates a default date format i.e. mm/dd/yyyy text within that input element. How do I remove this default text?
I tried adding below style on my page but it is hiding the selected date value as well,
input[type=date]::-webkit-datetime-edit-text { -webkit-appearance: none; display: none; } input[type=date]::-webkit-datetime-edit-month-field{ -webkit-appearance: none; display: none; } input[type=date]::-webkit-datetime-edit-day-field { -webkit-appearance: none; display: none; } input[type=date]::-webkit-datetime-edit-year-field { -webkit-appearance: none; display: none; }
The placeholder attribute does not work with the input type Date, so place any value as a placeholder in the input type Date. You can use the onfocus=”(this. type='date') inside the input filed.
< p >To disable the date field, double click the "Disable" button. // Set disabled = true.
The placeholder attribute specifies a short hint that describes the expected value of an input field (e.g. a sample value or a short description of the expected format). The short hint is displayed in the input field before the user enters a value.
::-webkit-datetime-edit-year-field:not([aria-valuenow]), ::-webkit-datetime-edit-month-field:not([aria-valuenow]), ::-webkit-datetime-edit-day-field:not([aria-valuenow]) { color: transparent; }
Possible option
HTML:
<input type='date' required>
CSS:
input[type=date]:required:invalid::-webkit-datetime-edit { color: transparent; } input[type=date]:focus::-webkit-datetime-edit { color: black !important; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With