How to detect a textarea and insert onKeyPress into that textarea using javascript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sithu Thwin
    New Member
    • Feb 2011
    • 2

    How to detect a textarea and insert onKeyPress into that textarea using javascript?

    I would like to detect a textarea in a form using javascript. And insert onkeypress into that textarea.
    I do no want to change original html code for textarea.
    I just want to add <script> tag in header section of a page and that <script> tag detect textarea in that page and insert onkeypress event into textarea
    Thanks.
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    Hi Sithu Thwin,
    Check out the function "getElementsByT agName()" it will work in Mozilla and alternate code are available for IE. This method will help you in getting the "Textarea" object. Use "setAttribu te" or .onKeyPress= or add Event Key Listener for that TextArea.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    Working...