Input Email readOnly Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field

Description

The readOnly property sets or gets whether an email field should be read-only.

This property reflects the HTML readonly attribute.

Set the readOnly property with the following Values

Value Description
true|false Sets whether an email field should be read-only
  • true - The email field is read-only
  • false - Default. The email field is not read-only

Return Value

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

The following code shows how to Set an email field to read-only:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

E-mail: <input type="email" id="myEmail" readonly>

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

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

<script>
function myFunction() {//from  w ww  .  java2s. co  m
    document.getElementById("myEmail").readOnly = true;
    
}
</script>
</body>
</html>

Related Tutorials