Input DatetimeLocal defaultValue Property

❮ Input DatetimeLocal Object

Example

Change the default value of a datetime field:

document.getElementById("myLocalDate").defaultValue = "2015-01-02T11:42:13.510";
Try it Yourself »

Description

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.


Browser Support

Property
defaultValue Yes 10.0 Yes Yes Yes

Note: The <input type="datetime-local"> element does not show any datetime field/calendar in Firefox.


Syntax

Return the defaultValue property:

datetimelocalObject.defaultValue

Set the defaultValue property:

datetimelocalObject.defaultValue = value

Property Values

Value Description
value Specifies the default value of the local datetime field


Technical Details

Return Value: A String, representing the default value of the local datetime field

More Examples

Example

Get the default value of a datetime field:

var x = document.getElementById("myLocalDate").defaultValue;
Try it Yourself »

Example

An example that shows the difference between the defaultValue and value property:

var x = document.getElementById("myLocalDate");
var defaultVal = x.defaultValue;
var currentVal = x.value;
Try it Yourself »

❮ Input DatetimeLocal Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.