Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Jquery How to handle paste? [duplicate]

Possible Duplicates:
How do you handle oncut, oncopy, and onpaste in jQuery?
jQuery catch paste input

I have a textarea, on paste to that textarea I want to

  1. format pasting values
  2. append to textarea

could that be done in Javascript?

like image 926
Njax3SmmM2x2a0Zf7Hpd Avatar asked Aug 23 '11 11:08

Njax3SmmM2x2a0Zf7Hpd


1 Answers

There is an onpaste event that works in modern day browsers:

$("#textareaid").bind("paste", function(){});

Problem with the event, it tells you that it is about to happen, but it doesn't give you what the user is pasting. JavaScript has restricted acccess to the clipboard and by default it is disabled. If the access is enabled you can read the clipboard data and than manipulate it.

like image 92
epascarello Avatar answered Oct 14 '22 17:10

epascarello