Make an editable textarea readonly using javascript function - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Make an editable textarea readonly using javascript function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w w  w  .ja v a  2 s  . c  o m
function readOnlyTextArea(idTextArea){
      document.getElementById(idTextArea).readOnly = "true";
};
readOnlyTextArea('my-box');
    }

      </script> 
   </head> 
   <body> 
      <textarea name="" id="my-box" cols="30" rows="10"></textarea>  
      <textarea name="" id="my-box-1" cols="30" rows="10">editable</textarea>  
   </body>
</html>

Related Tutorials