Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting html textarea's change

I'd like to monitor my textarea's changes with jQuery. I can do this with the keyup event and it works perfectly. But what event I can get when a user click on the textarea (right mouse click), then choose paste?

Click event occur only when the user click with the left mouse button on the textarea.

How can I handle this situation?

like image 484
Colby77 Avatar asked May 13 '10 19:05

Colby77


People also ask

Does textarea have Onchange?

The onchange property of a Textarea element refers to an event handler function that is invoked when the user changes the value in the text area and then “commits” those changes by moving keyboard focus elsewhere.

What is the difference between onInput and Onchange?

Definition and Usage The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus, after the content has been changed.

What can I use instead of Onchange?

All you need to do is use onInput instead of onChange . input. addEventListener('input', yourCallback);<Or>input.

How do I display HTML content in textarea?

Complete HTML/CSS Course 2022Use the <textarea> tag to show a text area. The HTML <textarea> tag is used within a form to declare a textarea element - a control that allows the user to input text over multiple rows. Specifies that on page load the text area should automatically get focus.


1 Answers

you can detect Pastes or Cuts into the textarea by:

$("#TextBox1").bind('paste', function(e) {
            alert('pasting text!');
        });
$("#TextBox1").bind('cut', function(e) {
            alert('cut text!');
        });

Or combine:

$("#Text1").bind('cut paste', function(e) {
    alert(e.type + ' text!');
});
like image 152
Glennular Avatar answered Sep 20 '22 19:09

Glennular