I found out that when pasting text (i.e. Hello
) by using the mouse, the following function will throw an empty popup:
$(\'input:text\').onpaste
$('input:text').bind('paste', function() {
alert($(this).val());
});
I don't think the bellow code works on IE8 since the input value is not changed when alert() executed.
$('input').bind('input paste', function(e) {
alert($(this).val());
});
on Firefox and Chrome, it works fine.
you can use the oninput
event instead, modern browsers support this method
http://jsfiddle.net/pxfunc/KDLjf/
$('input').bind('input', function(e) {
console.log($(this).val());
});
try this to get the data being pasted:
$("input:text").bind('paste', function(e) {
var text = e.event;
alert(text);
});
The timeout is needed to get the dom updated so the value is actually in the input field. you could also use the change event to check if the input box is updated http://api.jquery.com/change