Read Only Element



Write a javascript code to implement readOnly property of from element.


<html>
  <head>
    <title>ReadOnly Element in javascript</title>
      <script>

        function ReadOnly() 
        {
            document.forms.frm1.t1.readOnly = true;
        }
        
        function Enter() 
        {
            document.forms.frm1.t1.readOnly = false; 
        }

      </script>
    </head>
  <body>  

<form name="frm1">

 Enter your name: <input type="text" name="t1">

<input type="button" name="b1" value="Read Only" onclick="ReadOnly()">

<input type="button" name="b2" value="Write" onclick="Enter()">

    </form>
  </body>
</html>

Output: