locked
how to enable a textarea in javascript?

    Question

  • hi! i have a textarea that is currently disabled. using javascript how can enable it on button click?

    thanks in advance..

     

    Monday, August 13, 2007 2:14 PM

All replies

  • This content lifted from:
    http://www.w3schools.com/htmldom/prop_textarea_disabled.asp

    Disabling/enabling a textarea can be acomplished as follows:
    textareaObject.disabled=true|false
    Code Snippet

    <html>

    <head>
    <script type="text/javascript">
    function disable()
    {
    document.getElementById('txt1').disabled=true;
    }
    function enable()
    {
    document.getElementById('txt1').disabled=false;
    }
    </script>
    </head>
    <body>
    <textarea id="txt1">
    Hello world....This is a text area
    </textarea>
    <br />
    <input type="button" onclick="disable()" value="Disable" />
    <input type="button" onclick="enable()" value="Enable" />
    </body></html>


    Monday, August 20, 2007 4:44 AM
  • Thanks for the post. Exactly what I was looking for. The full code saved me some time of testing

    Friday, December 28, 2007 8:17 PM