Wednesday, 9 December 2015

How to disable copy cut paste in JQuery for input fields


How to disable copy cut paste in JQuery for input fields

$(document).ready(function(){
    $('selector').bind("cut copy paste",function(e) {
        e.preventDefault();
        alert('cut,copy & paste options are not allowed !!');
    });
});


Handle copy cut paste events in JQuery

$(document).ready(function() {
    $('selector').on('copy', function(event) {
        console.log("Handle copy event")
    });
    $('selector').on('cut', function(event) {
        console.log("Handle cut event")
    });
    $('selector').on('paste', function(event) {
        console.log("Handle paste event")
    });
});