Input Text defaultValue property
Example
Modify the default value of the text field:
document.getElementById("myText").defaultValue = "Goofy";
Try it »
Definition and Usage
The defaultValue property can set or return the default value of the text field.
Note: This default value is the value specified by the HTML "value" property.
Browser support

All major browsers support the defaultValue property.
Syntax
Return the defaultValue property:
textObject
.defaultValue
Set the defaultValue property:
textObject
.defaultValue=
value
Attribute values
| Value | Description |
|---|---|
| value | Describes the default value of the text field |
Technical details
| Return Value: | String, representing the default value of the text field |
|---|
More examples
Example
Get the default value of the text field:
var x = document.getElementById("myText").defaultValue;
x The output is:
Mickey
Try it »
The Input Text object