How to disable cut copy paste using jquery

In this post I am going to share a one line jquery code to disable cut copy paste feature on your web page. If there is some secured content on your web page and you don’t want to allow visitor to copy their content then you can put one line jquery code on your web page. Or you want to disable cut copy paste for specific input or textarea or any html element then you can do with this little code.



You must have seen a validation on banking website where in some case they ask your account number twice for confirmation, You don’t allow to copy paste the account number on banking website for confirmation, So you apply these types of validation using this jquery code and disable copy paste feature for specific input field to validate user enter their input manually.
disable-cut-copy-paste
First of all include jquery library on your page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

1. disabling cut copy paste feature for whole web page.

<script>
$('body').bind("cut copy paste", function(e) {
                            alert('Cut Copy Paste is disabled..');
                            e.preventDefault();
                        });
</script>

2. disabling cut copy paste feature for any html element by passing their ID or Class name

<script>
$('.disable').bind("cut copy paste", function(e) {
                            alert('Cut Copy Paste is disabled..');
                            e.preventDefault();
                        });
</script>

Add .disable class to which element you want to disable cut copy paste feature.



DEMO

If you like this post please don’t forget to subscribe my public notebook for more useful stuff