0

I have an input field , type='date'. I want to be able to enter the date in yyyy-mm-dd format and also show placeholder as yyyy-mm-dd. But the date always shows up at mm/dd/yyyy. How can it be fixed?

  <input
    type="date"
    name="input"
    required
    title="Enter a date in this format YYYY/MM/DD"
  />

https://codesandbox.io/s/sleepy-sun-3ext2

Kimaya
  • 1
  • 2
    Does this answer your question? [Is there any way to change input type="date" format?](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format) – Heretic Monkey Jan 24 '20 at 20:42

1 Answers1

0

Add this to your code and try

<input type="text" name="input" placeholder="YYYY-MM-DD" required pattern="(?:19|20)\[0-9\]{2}-(?:(?:0\[1-9\]|1\[0-2\])/(?:0\[1-9\]|1\[0-9\]|2\[0-9\])|(?:(?!02)(?:0\[1-9\]|1\[0-2\])/(?:30))|(?:(?:0\[13578\]|1\[02\])-31))" title="Enter a date in this format YYYY/MM/DD"/>
Kash
  • 329
  • 3
  • 15