[JavaScript] onkeypress and onchange event

  • onkeypress occurs when a keyboard key is pressed or held down
  • onchange occurs when the content of a field changes

Ok, let's go further. If you want to validate the character number limitation of one textarea control, which one you should choose?

I told you that the onchange is better. Because if you use copy text from somewhere to this control, the onkeypress will not be effected; while, the onchange will be worked well.

And now, I think you can distinguish the two JavaScript events easily.

posted @ 2011-03-18 17:49  On the road....  阅读(237)  评论(0)    收藏  举报