The readOnly
property sets or gets whether an email field should be read-only.
readOnly |
Yes | 10.0 | Yes | Yes | Yes |
Return the readOnly property.
var v = emailObject.readOnly
Set the readOnly property.
emailObject.readOnly=true|false
Value | Description |
---|---|
true|false | Set whether an email field should be read-only
|
A Boolean type value, true if the email field is read-only, otherwise false.
The following code shows how to get if an email field is read-only.
<!DOCTYPE html>
<html>
<body>
<!-- w w w. jav a 2 s. co m-->
E-mail: <input type="email" id="myEmail" readonly>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myEmail").readOnly;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to set an email field to be read-only.
<!DOCTYPE html>
<html>
<body>
<!-- ww w . j a va 2s . c o m-->
E-mail: <input type="email" id="myEmail">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myEmail").readOnly = true;
}
</script>
</body>
</html>
The code above is rendered as follows: