Easy Tutorial
❮ Prop Embed Type Event Animationend ❯

Password defaultValue Property


Definition and Usage

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

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

Syntax

Set defaultValue property:

Return defaultValue property:


Browser Support

All major browsers support the defaultValue property.


Example

The following example retrieves the default value of the password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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>

❮ Prop Embed Type Event Animationend ❯