Disable Cut, Copy and Paste function for textbox using jQuery

To disable cut, copy and paste functionality for the Textbox, which means User should not be allowed cut or copy text from the Textbox and also to paste text within Textbox. Well, it is very easy to do this using jQuery. All you need is to bind cut, copy and paste function to Textbox and stop the current action. See below code.

1 $(document).ready(function(){
2   $('#txtInput').live("cut copy paste",function(e) {
3       e.preventDefault();
4   });
5 });

You can also use bind function to bind these events.

1 $(document).ready(function(){
2   $('#txtInput').bind("cut copy paste",function(e) {
3       e.preventDefault();
4   });
5 });

See live Demo and Code.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s