It's impossible to use placeholder on date fields but I really need it.
I want two date inputs with texts "From" and "To" on each one as placeholders.
type='date')" onblur="(this. type='text')" Warning: Expected `onFocus` listener to be a function, instead got a value of `string` type. Warning: Expected `onBlur` listener to be a function, instead got a value of `string` type.
Use the ::placeholder pseudo-element to style your placeholder text in an <input> or <textarea> form element. Most modern browsers support this, but for older browsers, vendor prefixes will be required.
I'm using the following CSS only trick:
input[type="date"]:before { content: attr(placeholder) !important; color: #aaa; margin-right: 0.5em; } input[type="date"]:focus:before, input[type="date"]:valid:before { content: ""; }
<input type="date" placeholder="Choose a Date" />
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