1

I have a textbox named title and I would like to block people from being able to paste to it so that whatever content is in that textbox the user created it themselves by typing into it.You can see from below that i'm using the title textbox on keyup because i am transferring its values to another textbox which is hidden and if a user pastes on the title textbox then it will not go into the other textbox .As stated above I would like to be able to do this in Jquery but I can't seem to findout how

                       $("#title").keyup(function (e) {
                       $('#title').live("cut copy paste", function (e) {
                           e.preventDefault();
                       });
                           $("#threader_title").val($(this).val());

                   });
user1591668
  • 2,591
  • 5
  • 41
  • 84
  • why are you nesting it inside a `keyup` handler? Also would suggest upgrading from old version of jQuery that still has `live()` which has been deprecated for quite a few years now – charlietfl Jul 29 '14 at 00:17
  • Actually the Live() i just copied from http://www.codecomplete4u.com/disable-cut-copy-paste-in-textbox-or-textarea-using-jquery/ but yes I am looking to rework the whole thing. – user1591668 Jul 29 '14 at 00:22

1 Answers1

2

Not sure why you are using .live().

From jQuery's API Website:

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers.

Try this:

$(document).ready(function(){
    $(document).on("cut copy paste","#title",function(e) {
        e.preventDefault();
    });
 });

JSFiddle Demo

imbondbaby
  • 6,351
  • 3
  • 21
  • 54