In Jquery How to handle paste?
20,018
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.
Author by
Njax3SmmM2x2a0Zf7Hpd
Updated on July 03, 2020Comments
-
Njax3SmmM2x2a0Zf7Hpd almost 4 years
Possible Duplicates:
How do you handle oncut, oncopy, and onpaste in jQuery?
jQuery catch paste inputI have a textarea, on paste to that textarea I want to
- format pasting values
- append to textarea
could that be done in Javascript?
-
jobmo about 7 yearsDoesn't
e.target.value
give you what the user is pasting? -
epascarello about 7 years@jobmo Well a bit has changed in the 6 years that this was answered. You get what was pasted with event.clipboardData. Reading the value will get you the entire contents of the textarea.
-
Bernhard Döbler almost 6 years
e.target.value
does not necessarily contain the value. You might needsetTimeout
stackoverflow.com/a/1503425/577052 -
Bernhard Döbler almost 6 years
event.clipboardData
does not exist in IE11