Given an input element:
<input type="date" />
Is there any way to set the default value of the date field to today's date?
datehtmlinput
Given an input element:
<input type="date" />
Is there any way to set the default value of the date field to today's date?
Best Answer
Like any HTML input field, the browser will leave the date element empty unless a default value is specified within the
value
attribute. Unfortunately, HTML5 doesn't provide a way of specifying'today'
in theHTMLInputElement.prototype.value
.One must instead explicitly provide a RFC3339 formatted date (
YYYY-MM-DD
). For example: