Prevent or Disable Copy or Paste In Input Fields

Using jQuery we can disable or prevent copy or pasting of input fields, jQuery has built-in access to this functionality in browsers by exposing them as events, that is by binding any input element like text input, text area, etc, with these events and calling the preventDefault() event which prevents the user from copy or pasting text into these fields. We observe these in many forms, especially ones those of more secure websites(like online banking). Check out the below snippets of its implementation.

Disable Copying

$('input').bind('copy', function(e) { e.preventDefault(); });

Disable Copying and Pasting

$('input').bind('copy paste', function(e) { e.preventDefault(); });
  • Nice Tip

  • This function is important for secure website and also to protect copyrighted content (text) on our website.

  • MichaelC

    Thank you, works well.