-3

Possible Duplicate:
How do I disable right click on my web page?

I want to disable right click and Ctrl+V & Ctrl+C keypresses on a web page using JavaScript. I have a page where customers has to enter the enquiry details. I don't want them to copy some data and paste it in some fields. Anyone, please help me.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Riya
  • 529
  • 4
  • 10
  • 18
  • 3
    Why, in god's name, why?! Will you also disable the Edit menu or any other possible method how something can be pasted? – deceze Jun 06 '12 at 06:56
  • 4
    Oh, and if it's e.g. for a "repeat your email" field: EXTREMELY ANNOYING. I use autocompletion for the first one so copy&paste is perfectly safe! Stop restricting your users in annoying ways. Thanks! – ThiefMaster Jun 06 '12 at 07:00
  • 3
    Why would you want to prevent copy-pasting the data? If you force people to retype the same thing, they're just more prone to make typos or leave something out. The copy-paste is also for *your* benefit. – JJJ Jun 06 '12 at 07:09
  • 1
    `$(document).bind('copy', function(e) { alert('Copy is not allowed !!!'); e.preventDefault(); }); $(document).bind('paste', function() { alert('Paste is not allowed !!!'); e.preventDefault(); }); $(document).bind('cut', function() { alert('Cut is not allowed !!!'); e.preventDefault(); }); $(document).bind('contextmenu', function(e) { alert('Right Click is not allowed !!!'); e.preventDefault(); });` – Varun Naharia May 08 '15 at 09:03

1 Answers1

4

Try this:


Check this link Disabling-the-right-click-on-web-page

<script language="javascript">
document.onmousedown=disableclick;
status="Right Click Disabled";
Function disableclick(e)
{
  if(event.button==2)
   {
     alert(status);
     return false;  
   }
}
</script>
Vinod
  • 4,672
  • 4
  • 19
  • 26