Text value Property
Text Object
Definition and Usage
The value property sets or returns the value of the value attribute of a
text field.
The value property contains the default value OR the value a user types in
(or a value set by a script).
Syntax
Set the value property:
Return the value property:
Browser Support

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