Prevent People from Copying Text on Web Pages

If, for some reason, you would like to prevent users from copying and pasting text from your web pages through Ctrl-C Ctrl-V, or using the mouse, jQuery can help.

$('body').bind('copy paste cut drag drop', function (e) {
  e.preventDefault();
});

The bind function attaches an event handler to the main body element and prevents the clipboard functions for all the elements on the page. Use can however still copy text though the DOM tree that can be accessed using the Chrome Dev Tools.

Also, if you would like to disable cut-copy-paste operations on certain fields - like the password input field or the text area, the following snippet should help. When the copy or cut event is fired, nothing happens.

$('input[type=text],textarea').bind('copy paste cut drag drop', function (e) {
  e.preventDefault();
});

Amit Agarwal is a web geek, solo entrepreneur and loves making things on the Internet. Google recently awarded him the Google Developer Expert and Google Cloud Champion title for his work on Google Workspace and Google Apps Script.

Awards & Recognition

Google Developer Expert

Google Developer Expert

Google awarded us the Developer Expert title recogizing our work in Workspace

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional title for 5 years in a row

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator award for technical expertise

Want to stay up to date?
Sign up for our email newsletter.

We will never send any spam emails. Promise 🫶🏻