X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Input Text defaultValue Property

Input Text Object Reference Input Text Object

Example

Change the default value of a text field:

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

Try it yourself »


Definition and Usage

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

Note: The default value is the value specified in the value attribute.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The defaultValue property is supported in all major browsers.


Syntax

Return the defaultValue property:

textObject.defaultValue

Set the defaultValue property:

textObject.defaultValue=value

Property Values

Value Description
value Specifies the default value of the text field

Technical Details

Return Value: A 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;

The result of x will be:

Mickey

Try it yourself »


Input Text Object Reference Input Text Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook