Reputation: 2034
I have come across this and found many solutions but none fits my issue.
<input type="date" #evtDate required name="evtDate" placeholder="Select Event Date" id="evtDate" formControlName="eventDate">
It's displayed on the browser as:
I want to show a string placeholder here, something like:
I achieved this using CSS like,
input[type="date"]::before {
content: attr(placeholder);
width: 100%;
}
input[type="date"]:focus::before,
input[type="date"]:valid::before { display: none }
This part has an issue here when I click on its date icon, the date input is again changed to normal format, like:
If I don't use this CSS part, it still shows the custom placeholder value but doesn't update anything on the input.
// input[type="date"]:focus::before,
// input[type="date"]:valid::before { display: none }
I also checked that there's some dynamic HTML created for this input type="data", and that needs to be kept for data to set in that format.
Can anyone please suggest how this can be done? Thanks in advance!
Upvotes: 3
Views: 10736
Reputation: 378
onfocus="(this.type='date')" onblur="(this.type='text')"
HTML<------>
<div>
<label for="date">Date : </label>
<input placeholder="Your Date" type="text" onfocus="(this.type='date')" onblur="(this.type= this.value ? 'date' : 'text')">
</div>
Upvotes: 0
Reputation: 1943
You can try these code
<input type="text" placeholder="Date" onfocus="(this.type='date')"/>
Upvotes: 1