Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Text defaultValue property

Input Text defaultValue property

Input Text Object Reference The Input Text object

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

Internet Explorer Firefox Opera Google Chrome Safari

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 »


Input Text Object Reference The Input Text object