Search code examples
javascriptjquerycontenteditable

Disabling pasting completely in [contenteditable] div's


I'm having the luck of having to work with multiple contenteditable divs instead of textareas. I fixed almost everything, but can't find a way to completely disable pasting into the div:

$(document).on('paste',function(e) {
    e.preventDefault();
});

The paste-event does fire, but the text still gets pasted. This only has to work on Chrome (latest). Does anyone have a solution?


Solution

  • You just need to return false

    $(document).on('paste',function(e) {
        e.preventDefault();
        return false;
    });