2

I'm trying to create a form but I don't want to use labels, I just want to use the placeholder to let the user know what is asked from him. But when I give it type="date" the placeholder in Chrome is ignored and replaced with: day-month-year, but I want it to display: Date of birth.

I there a way to do this? Otherwise I have to change the entire form and insert labels.

I know it's been asked before, but everyone wants to prevent the datepicker to display, I do like the datepicker but just not placeholder. All answers I found were based on the placeholder.

TheLD
  • 2,211
  • 4
  • 21
  • 26
  • http://stackoverflow.com/questions/8574356/html5-placeholder-disappears-on-focus This jQuery plug in should stop that happening. – joshuahornby10 Nov 28 '12 at 12:18
  • http://stackoverflow.com/questions/12860851/how-do-i-change-the-html5-placeholder-text-that-appears-in-date-field-in-chrome – int32_t Nov 28 '12 at 23:29
  • This can be helpful. http://stackoverflow.com/questions/25018653/remove-placeholder-from-date-type-input-in-chrome – Bhanu Pratap Singh Oct 29 '15 at 21:01
  • Possible duplicate of [Remove default text/placeholder present in html5 input element of type=date](http://stackoverflow.com/questions/28686288/remove-default-text-placeholder-present-in-html5-input-element-of-type-date) – Maks3w Mar 02 '16 at 08:27

1 Answers1

2

The placeholder attribute is not valid on input type="date". So the easiest way to get placeholder to work is to set the type to something that supports it.

Also note:

The placeholder attribute should not be used as an alternative to a label.

If you are determined to use your approach you should add labels to your form then make sure they're available to assistive technology.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • Well this explains why `placeholder="YYYY/MM/DD"` doesn't work... but how to set a type to something that support it when you need the native date input? – Michael Apr 17 '16 at 01:54