Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  84] [ 5]  / answers: 1 / hits: 28516  / 13 Years ago, thu, may 19, 2011, 12:00:00

Is there a library that can extract all text events from an <input type=text> (or contentEditable -- any one-line input field) element?



In particular, I need to know whenever the text is changed by:




  • typing (asdf, backspace)

  • cut/paste

  • key combo actions (e.g. ctrl+bksp or option+bksp deletes the previous word)

  • dragged & dropped text

  • edit menu actions



And preferably what it was that changed (whether and what text was inserted, deleted, or replaced).



Needs to work on Chrome, Safari, Firefox 3+, IE9+.


More From » events

 Answers
87

The HTML5 oninput event is supported by all those browsers and works very much like the onchange event, but fires as soon as the element's input changes. It also bubbles, so you can capture it further up the document tree.



element.oninput = function () {

}


Working demo: http://jsfiddle.net/Zfthe/



http://whattheheadsaid.com/2010/09/effectively-detecting-user-input-in-javascript


[#92159] Tuesday, May 17, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nicole

Total Points: 648
Total Questions: 95
Total Answers: 103

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;