Latest web development tutorials

HTML DOM Password value property

Password Object Reference Password objects

Definition and Usage

value property sets or returns the property value of the password field.

For security reasons, some browsers may prevent JavaScript code reads the value property.

grammar

Set the value property:

passwordObject.value="value"

Returns the value property:

passwordObject.value


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support attribute value


Examples

Examples

The following examples available Default password fields:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("pwd").value;
    alert(x);
}
</script>
</head>
<body>

<form>
密码: <input type="password" id="pwd">
</form>
<button type="button" onclick="displayResult()">显示值</button>

</body>
</html>

try it"


Password Object Reference Password objects