Safari JS cannot parse YYYY-MM-DD date format?

后端 未结 4 2155
[愿得一人]
[愿得一人] 2020-11-28 10:38

In a project I am working on, I need to validate a date entered into an

With Safari 4/5 (on Mac OSX) the Javascript fails to

4条回答
  •  旧时难觅i
    2020-11-28 10:59

    the field should accept any date format

    You don't mean what you think you mean.

    • It's difficult to reliably distinguish between M/D/Y (US) and D/M/Y (UK). D.M.Y is more common in the UK, but by no means universal.
    • Good luck with dates before around 1600 — the Gregorian (solar) calendar was introduced in 1582, and was only (mostly universally) adopted in the 20th century (Wikipedia gives 1929). February 30 was a valid date Sweden.
    • OS X gives you a choice of 13 (!) calendars, though the default is Gregorian.

    Instead, I recommend using a calendar widget. I think JQuery has one, but ICBW.

提交回复
热议问题