Change the default value of a datetime field:
The defaultValue property sets or returns the default value of a local datetime field.
Note: The default value is the value specified in the HTML value attribute.
The difference between the defaultValue and value property, is that defaultValue contains the default value, while value contains the current value after some changes have been made. If there are no changes, defaultValue and value is the same (see "More Examples" below).
The defaultValue property is useful when you want to find out whether the local datetime field have been changed.
The defaultValue property is supported in all major browsers.
Note: The <input type="date"> element is not supported in Internet Explorer or Firefox.
Return the defaultValue property:
Set the defaultValue property:
Value | Description |
---|---|
value | Specifies the default value of the local datetime field |
Return Value: | A String, representing the default value of the local datetime field |
---|
Get the default value of a datetime field:
The result of x will be:
An example that shows the difference between the defaultValue and value property: