Input Password type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

The type property returns the type of form password field.

For a password field, this property will always return "password".

Return Value

Type Description
String The type of form element the password field is

The following code shows how to check which type of form element the password field is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Password: <input type="password" id="myPsw">

<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/* www. j  a va2  s .  c  o  m*/
    var x = document.getElementById("myPsw").type;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials