teepusink teepusink - 1 year ago 215
Javascript Question

Textarea onchange detection

How do I detect change event on textarea using javascript?

I'm trying to detect how many characters left is available as you type.

I tried using the onchange event, but that seems to only kick in when focus is out.

Answer Source

You will need to use onkeyup and onchange for this. The onchange will prevent context-menu pasting, and the onkeyup will fire for every keystroke.

See my answer on How to impose maxlength on textArea for a code sample.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download