I catch insert events with $('selector').on('input', function(event) { ... });
Then I try to check what was inserted, and if it fails, cancel the insert using event.preventDefault() . Unfortunately, by the time the listener function is complete, the text is already inserted and event.preventDefault() does nothing.
So, what is a good way to catch insert events, and if what was inserted does not check, cancel / prevent insertion?
I know that I can use .on('paste', function(event) { ... }) , but this does not give me the text that was inserted, or the contents of the input element after pasting, unless I use setTimeout() with by some minute wait time, d would like to avoid using setTimeout() .
javascript jquery html html5 javascript-events jquery-events paste
Valera
source share