If the input field is required, you can use : an invalid selector , for example:
input[type=date]:invalid::-webkit-datetime-edit { color: #999; }
<input type="date" required /><br>
Another solution is to add a class to the input that you delete when you enter a value.
var el = document.getElementById('date'); el.onchange = function() { if (el.value === '') { el.classList.add("empty"); } else { el.classList.remove("empty"); } }
.empty { color: #999; }
<input type="date" id="date" class="empty" />
NOTE. My second example (with class) will be applied in all browsers.
A similar question has already been answered, but it did not help me.
source share