Disable Copy or Paste action for text box

jQuery preventDefault()

The event.preventDefault() method stops the default action of an element from happening. You can use this method toprevent a TextBox control from Cut (Ctrl+X) , Copy (Ctrl+C) and Paste (Ctrl+V) .
$('.myTextBox').bind('copy paste cut',function(e) { e.preventDefault(); alert('cut,copy & paste options are disabled !!'); });
<input type="text" class="myTextBox" />
run this source code Browser View

Type something and try to copy it

Full Source
<!DOCTYPE html> <html lang="en"> <head> <title>Disabled Cut, Copy and Paste</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('.myTextBox').bind('copy paste cut',function(e) { e.preventDefault(); //disable cut,copy,paste alert('cut,copy & paste options are disabled !!'); }); }); </script> </head> <body> <p>Type something and try to copy it</p> <input type="text" class="myTextBox" /> </body> </html>

How to Prevent Cut Copy Paste on all textboxes?

You can use the following method to prevent all textboxes in a form using jQuery.

$('input:text').bind('cut copy paste', function(e) { e.preventDefault(); alert("Cut / Copy / Paste Disabled"); });
<input type="text" class="myTextBox1" /> <input type="text" class="myTextBox2" /> <input type="text" class="myTextBox3" />
run this source code Browser View

Type something and try to copy it

Full Source
<!DOCTYPE html> <html lang="en"> <head> <title>Disabled Cut, Copy and Paste on all textboxes</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('input:text').bind('cut copy paste', function(e) { e.preventDefault(); alert("Cut / Copy / Paste Disabled"); }); }); </script> </head> <body> <p>Type something and try to copy it</p> <input type="text" class="myTextBox1" /> <input type="text" class="myTextBox2" /> <input type="text" class="myTextBox3" /> </body> </html>