Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a iframe which is used as rich text box editor means entered text can be bold/italic/underline.

if user paste data in this frame I just want to put some restriction on that data before pasted. like if user tried to paste some script or some restricted XSS content just restrict them.

The solution should work for chrome and edge browser.

Thanks,

What I have tried:

I have tried below code-

iframeElement.addEventListener('paste',function(e){
var text=e.clipboardData.getData('text/plain')
// put validtion
// then prevent to paste
e.preventDefault();
// show error message to user
});
Posted
Updated 20-Sep-22 1:23am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900