Subscribe - It's FREE!!

Stay Connected Here

Stay Updated With Us Here


How to disable copy paste in textbox using jQuery

Share with WhatsApp

Hello friend, in this post I am going to share simple way of disabling Cut, Copy and Paste operation in input textbox using jQuery. It prevents user to perform any of these operations including shortcuts like Ctrl+C, Ctrl+X and Ctrl+V and right click too.

Many developers are not aware that there are events exist for each of this operation so they achieve it by detecting the keycode on keydown/up event and so on.  This thing made me to share this information here so while reading other post you will come to know about this if not already known to you.

Let’s check the code first.


      $('#input1').bind("cut copy paste",function(event) {


That’s it. Above is the only code to restrict cut, copy and paste all together on textbox. Isn’t it cool?

For beginners, let’s discuss how the code is working.

As like jQuery tagline "Write Less, Do More" in above code I have bind multiple events together to the input having id “input1”  and just called a action preventDefult() of event object in it.

event.preventDefault() is an action which prevents the default action to be triggered when called therefore nothing happens when any of the above event gets triggered.

If you want to know more about event.preventDefault() you can visit here.

You can say this solution as cross browser solution as its support almost all browsers if gets used for input element. I have tested it for IE8+, Firefox and Google chrome. For detailed compatibility you can check at this link at

Hope you have benefited this simple but useful code.

Feel the joy of sharing by any of the share button provided. Do not forget to share your comments too. Thanks.

Below is live fiddle of the above code.

If you enjoyed this post take 5 seconds to share it! Be Socialable. :-)

Share with WhatsApp

Posts To Read Next

Typewriter - Automatic TypeScript Template generation from C# classes in Visual Studio

Typewriter, an extension for visual studio that generates TypeScript files from C# code files using TypeScript templates. Convert your C# model classes to TypeScript automatically.

How to call click or any event only once in jQuery

Know how to execute an click event or any event only once for any element in jQuery. Perform action only once and even not required to unbind event.

Top 10 Visual Studio things which can boost developers coding speed

Visual Studio 2012 provides some coding features by which you can code faster if use them properly. This post will cover top 10 things among them to boost your development speed.

Copy changed data in table from one database to another in SQL stored procedure

How to copy or merge changed data in table from one database to another having same schema is the topic of this post.

Swagger - Powerful Opensource Framework for RESTful API

With a Swagger-enabled API, you get interactive documentation, client SDK generation and discoverability. Swagger Editor allows you to generate code, documentation with ease.

Your opinion is valuable for us! Comments, suggetions are welcome.

Submit your Email Id to stay updated with us and get notified with our new posts. It's FREE!
Vu 32'' TV Vu 24'' TV
We know this popup is disturbing you!
But We would greatly appreciate if you share us with your friends below!

It will not take more than 2 seconds but will motivate us greatly to write more,share more!