Wednesday 19 September 2012

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.

No comments:

Post a Comment