Easy Tutorial
❮ Jsref Ln10 Coll Doc Images ❯

defaultValue Property

Input Text Object

Example

Modify the default value of a text field:

document.getElementById("myText").defaultValue = "Goofy";

Definition and Usage

The defaultValue property sets or returns the default value of a text field.

Note: This default value is the one specified in the HTML "value" attribute.


Browser Support

All major browsers support the defaultValue property.


Syntax

Return the defaultValue property:

Set the defaultValue property:

Property 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 a text field:

var x = document.getElementById("myText").defaultValue;

x outputs:

Mickey

❮ Jsref Ln10 Coll Doc Images ❯