Jump to content

prevent user using ctrl v to paste


jasonc

Recommended Posts

I found this on the web. It disables a little more than ctrl-v:

 

function disableCtrlModifer(evt)
{
var disabled = {a:0, c:0, x:0, v:0};
var ctrlMod = (window.event)? window.event.ctrlKey : evt.ctrlKey;
var key = (window.event)? window.event.keyCode : evt.which;
key = String.fromCharCode(key).toLowerCase();
return (ctrlMod && (key in disabled))? false : true;
}

 

Call it this way:

 

<input type="text" name="mytext"
        onkeypress="return disableCtrlModifer(event);"
        onkeydown="return disableCtrlModifer(event);" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.