By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,373 Members | 1,792 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,373 IT Pros & Developers. It's quick & easy.

Prevent right click paste in Rich Text Editor

arnabc
P: 6
Hi all,

I am developing one online forum kind of website where users have the facility to submit there comments and to do that we r using one custom made rich text editor. So far it was fine but suddenly I discovered that one can paste a large amount of text or a Big Image in the Rich text editor which was not a desired thing because we set up a maximum limit of text one can enter and the Big image problem is that we have the option to insert smileys so distinguishing the pasted image from the smileys is a problem. So then to prevent this we tried to disable the "ctrl + v" function using key code checking in JavaScript it was working fine but I am not able to prevent it if in case anyone right clicks in that editor and selects "paste" from there. Do you guys have any suggestion regarding this or any useful commment which can help me to find a workable solution. Thanks in advance.
Jul 3 '07 #1
Share this Question
Share on Google+
2 Replies


acoder
Expert Mod 15k+
P: 16,027
Instead of trying to prevent right-click, just check for the length of the text input when submitting the form or when a key is pressed. If someone disables Javascript, you won't be able to prevent them right-clicking. Javascript checking is useful, but you should never depend on it - always make a check on the server-side too.
Jul 3 '07 #2

arnabc
P: 6
Instead of trying to prevent right-click, just check for the length of the text input when submitting the form or when a key is pressed. If someone disables Javascript, you won't be able to prevent them right-clicking. Javascript checking is useful, but you should never depend on it - always make a check on the server-side too.

Ya I am checking the length of the text in keypress but for right click "paste" the keypress event doesn't fire and that's the problem. I also have server side checking for text length which is working fine chopping extra inputs but the main problem is with the IMAGE as I am unable to determine whether it's a smiley or a pasted image that's why I was trying to prevent pasting operation in RTE, just to stop pasting Images into the editor. Anyway thanks for your reply.
Jul 3 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.