0

I want to detect if textarea value is modified. here is whatever I've done- html:

<textarea id="textarea" autofocus></textarea>

js:

var textarea = document.getElementById("textarea");
textarea.onpaste = textarea.onkeypress = function() { 
  isModified = true;
};

I know there is another option, onchange but that won't work here because the textarea is autofocused and the onchange event wont work until the textarea is blured. and I don't want to blur the textarea.

So my question is that are there any other option of doing so? Thanks.

Dom
  • 38,906
  • 12
  • 52
  • 81
b134692
  • 83
  • 1
  • 7
  • `onkeyup` event can do the job. – Dvir Oct 19 '13 at 20:49
  • The event handler can be unsubscribed on first run. This would remove the overhead of triggering for every click. – Praveen B Oct 19 '13 at 20:53
  • If you don't need it in real-time (each letter as they type), you can use onfocus and record the value with a setInterval() set to like 2 or 3 seconds, depending on your end goal. – Deryck Oct 19 '13 at 21:01

1 Answers1

-4

Check the Javascript on this page (something that I built loooong ago), it might help you. :) http://www.frofens.org/myvirtualnotepad/demo/

Christian Dechery
  • 876
  • 10
  • 31