Javascript Reference - HTML DOM Input Password type Property








The type property gets the type of a password field.

Browser Support

type Yes Yes Yes Yes Yes

Syntax

var v = passwordObject.type 

Return Value

A String type value representing the type of the password field.





Example

The following code shows how to get the type of the password field.


<!DOCTYPE html>
<html>
<body>
<!--  w ww .j a va  2s  . c om-->
Password: <input type="password" id="myPsw">
<button onclick="myFunction()">test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myPsw").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: