HTML DOM Password value property
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
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>
<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 objects