Password defaultValue Property
Password Object
Definition and Usage
The defaultValue property sets or returns the default value of a
password field.
Note: The default value is the value specified in the HTML "value"
attribute.
Syntax
Set the defaultValue property:
passwordObject.defaultValue="value"
Return the defaultValue property:
passwordObject.defaultValue
Browser Support

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