views:

62

answers:

2

Hii, I have to take the paste event of a text area using JQuery. I have tried the following code but it is not working...

$(document).ready(function()
{ 
  $('#txtcomplaint').keyup(function()
  {  
     TextCounter('txtcomplaint','counterComplaint', 1000 ); 
  }) 
  $('#txtcomplaint').onpaste(function()
  {  
     alert()
     //TextCounter('txtcomplaint','counterComplaint', 1000 ); 
  }) 
});
+2  A: 
$('#txtcomplaint').bind('paste', function(e){ alert('pasting!') });

For additional resource take a look here.

Mendy
You won't get the copied text using this method.
rahul
@rahul: He only want to use this event for text counting porpoise.
Mendy
+1  A: 

You can do something like this

$("#txtcomplaint").bind('paste', function(e) {
    var elem = $(this);

    setTimeout(function() {
        // gets the copied text after a specified time (100 milliseconds)
        var text = elem.val(); 
    }, 100);
rahul