Text defaultValue Property
Text Object
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.
Syntax
Set the defaultValue property:
textObject.defaultValue="value"
Return the defaultValue property:
Browser Support

The defaultValue property is supported in all major browsers.
Example
Example
Display the default value of the text field:
<html>
<head>
<script>
function displayResult()
{
var x=document.getElementById("email").defaultValue;
alert(x);
}
</script>
</head>
<body>
<form>
Email: <input type="text" id="email" value="someone@example.com">
</form>
<button type="button" onclick="displayResult()">Display default value</button>
</body>
</html>
Try it yourself »
Text Object
Thank You For Helping Us!
Your message has been sent to W3Schools.
Close [X]