Password typeProperty

Password 对象参考手册Password Object

Definition and Usage

The type property returns the type of the form element.

For a password field, this property is always "password".

Syntax

passwordObject.type


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the type property


Example

Example

The following example returns the form element type of the password field:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function displayResult(){
    var x=document.getElementById("pwd").type;
    alert(x);
}
</script>
</head>
<body>

<form>
Password: <input type="password" id="pwd">
</form>
<button type="button" onclick="displayResult()">Show input type</button>

</body>
</html>

Try it Yourself »


Password 对象参考手册Password Object Other Extensions