Reputation: 153
Would like to disable right click or Ctrl C on a specific text field which is set to 'readonly'.
The value of this field is expected to be typed into another field without being copied and pasted.
Here is what I"ve:
<input onfocus="disableCaptchaCopy();" id="capId" type="text" value="<?php echo $gen_c; ?>" name="gen_c" readonly="readonly" />
Javascript function:
function disableCaptchaCopy() {
var capField = document.getElementsById(capId);
if (capField != null) {
field.oncut = function() { return false; };
}
}
Would be please if anyone could help out.
Upvotes: 0
Views: 1713
Reputation: 2768
Not entirely valid but works in various different browsers including the latest versions of Firefox, IE and Chrome:
<input type="text" name="field" onpaste="return false" />
This doesn't prevent your text being copied, but it does prevent it being pasted into the subsequent field.
Upvotes: 2