I have inputbox. When page load, i use mouse to right click inputbox and choose paste from contextmenu.
when text get pasted, which event to use to alert text insta
There is a better way now. Still not all browsers support this 2011, but this will change
oninput event handler
oninput fixes
more fixes
and other crossbrowser jquery solutions
You can bind these events like so:
$(document).ready(function() {
$("#Text1").bind('copy', function(e) {
alert('copying text!');
});
$("#Text1").bind('paste', function(e) {
alert('pasting text!');
});
$("#Text1").bind('cut', function(e) {
alert('cut text!');
});
});
A hack that would work most of the time would be to hook into the control's onchange
while also storing the control's initial text in a separate variable. Any time the length of the new text is longer than the original text by more than one character, you can assume that something was pasted in. Obviously this wouldn't work if someone pasted in a one-character string, but people don't do that very often.
It was set an action with setInterval (javascript function), which checks every 200ms the content of input. If it is changed then the past or typing occurred.