Input Password readOnly Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

The readOnly property sets or gets whether a password field is read-only.

Set the readOnly property with the following Values

Value Description
true|false? Sets whether a password field should be read-only

Return Value

A Boolean, returns true if the password field is read-only, otherwise it returns false

The following code shows how to Set a password field to read-only:

Demo Code

ResultView the demo in separate window

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

<button onclick="myFunction()">Set read-only</button>

<script>
function myFunction() {// w  w  w .  j  a va  2 s  .  co  m
    document.getElementById("myPsw").readOnly = true;
}
</script>

</body>
</html>

Related Tutorials