I have read How do I detect any change to a textarea? and Textarea onchange detection, but these do not answer my question. I use a function to load the contents of a few input fields, and a textarea via an AJAX call. I know I can just attach a function call to the end of the func that does the call and modifies the contents, but it still doesn't solve my problem, because clicking on the "Reset" form button does not trigger an "oninput
", or "oncut
", or "onpaste
", or "oncopy
". Is there an event that does get triggered when programmatic changes to a textarea or input occur? Or do I just have to manually hack it in?
Asked
Active
Viewed 647 times
0
-
2Couldn't you just attach the same function to the form reset action? – Scott Harris Oct 28 '14 at 22:08
-
Yes, but this is the kind of solution I want to avoid. If I used a large number of buttons or functions that did different changes to the same textarea, it would require each of these to also run the function, whereas if theres a viable "oncontentchange" type listener/event, then that would make it trivial -- just one function call total. – insaner Oct 28 '14 at 22:13
-
It's simplest to just add it to the reset function or whatever other functionality you have. If that's not an option you can look at mutations, but that gets pretty complicated when you want crossbrowser support – orhanhenrik Oct 28 '14 at 22:13
-
Similar to http://stackoverflow.com/questions/19432171/javascript-how-to-detect-a-programmatic-value-change-on-a-select-element-drop – soktinpk Oct 28 '14 at 22:24
2 Answers
1
I eventually found an answer to this here: Textarea onchange detection
Using
<textarea oninput="myfunc(this)" onpropertychange="myfunc(this)">
solved it for me, and this is supposed to work for IE8 as well.

insaner
- 1,641
- 16
- 28
0
The only thing I can suggest is add a data attribute to the textarea. In your programmatic updates keep both in sync. Then, you can check for input updates.
<textarea data-p-value="" value=""></textarea>

beautifulcoder
- 10,832
- 3
- 19
- 29