4

I'm using razor view page and in date time field i want to display placeholder, its showing in Firefox but not showing in chrome its show - mm/dd/yyyy.

Hers is my code -

 @Html.EditorFor(model => model.Date, new { htmlAttributes = new { @class = "form-control form-inline", @placeholder = "Date must be today's or past date" } })

Screenshot of firefox

Screenshot of  chrome

How can i resolve this issue.??

Keyur Shah
  • 536
  • 6
  • 20
Ashvin
  • 211
  • 2
  • 11
  • Chrome only allows "international" date formats when rendering inputs with a `type="date"` value, by default. Your placeholder would need to be `YYYY/MM/DD`. Also, you only need to use the `@` operator to escape reserved words (like `class`) - it's not needed for placeholder. See http://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format – Tieson T. Jan 30 '17 at 02:48

1 Answers1

0

The date type doesn't support placeholder attribute. Also, the WebKit implementation says it's fixed.

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary

MartinWebb
  • 1,998
  • 1
  • 13
  • 15