469,914 Members | 2,480 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,914 developers. It's quick & easy.

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.
Feb 5 '11 #1
1 2120
RamananKalirajan
607 512MB
Hi Sithu Thwin,
Check out the function "getElementsByTagName()" it will work in Mozilla and alternate code are available for IE. This method will help you in getting the "Textarea" object. Use "setAttribute" or .onKeyPress= or add Event Key Listener for that TextArea.

Thanks and Regards
Ramanan Kalirajan
Feb 8 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Joe Fallon | last post: by
2 posts views Thread by AmitKu | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.