Easy Tutorial
❮ Prop Video Videotracks Met Canvas Fill ❯

Password readOnly Attribute


Definition and Usage

The readOnly attribute sets or returns whether the password field is read-only.

Read-only fields cannot be modified. However, users can select and copy the text.

Syntax

Set readOnly attribute:

Return readOnly attribute:


Browser Support

All major browsers support the readOnly attribute.


Example

The following example sets the password field to read-only:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>tutorialpro.org(tutorialpro.org)</title>
<script>
function setResult(){
    document.getElementById("pwd").readOnly=true;
}
</script>
</head>
<body>

<form>
Password: <input type="password" id="pwd">
</form>
<button type="button" onclick="setResult()">Set Read-Only</button>

</body>
</html>
❮ Prop Video Videotracks Met Canvas Fill ❯