How to set input type date's default value to today?

后端 未结 30 3479
刺人心
刺人心 2020-11-22 14:00

The HTML5 input types are great, Opera\'s new built-in date picker is a breeze, and Chrome has at least supported the new input type with a spin-wheel implementation.

<
30条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 14:15

    Like any HTML input field, the browser will leave it empty unless a default value is specified with the value attribute.

    Unfortunately HTML5 doesn't provide a way of specifying 'today' in the value attribute (that I can see), only a RFC3339 valid date like 2011-09-29.

    TL;DR Use YYYY-MM-DD date format or it won't display

提交回复
热议问题