Page 1 of 1
Disable copy/paste with php?
Posted: Mon Mar 29, 2010 12:35 pm
by lauthiamkok
Hi,
I wonder if there is any way to disable [cntl + c] and [cntl + v] from an input field to another input field with php?
I can do this easily with jquery below, but what if I turn off javascript on my browser - it won't work for sure...
Code: Select all
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$('#message_email').bind('paste', function(e){
alert('Sorry, pasting is not allowed. Please type in.');
return false;
});
});
</script>
</head>
<body>
<div><input name="message_email" id="message_email" type="text"/></div>
</body>
</html>
Many thanks,
Lau
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 1:05 pm
by requinix
No. There is no way. And personally, I hate it when people try to do that.
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 2:11 pm
by omniuni
lauthiamkok wrote:Hi,
I wonder if there is any way to disable [cntl + c] and [cntl + v] from an input field to another input field with php?
I can do this easily with jquery below, but what if I turn off javascript on my browser - it won't work for sure...
Many thanks,
Lau
You could try binding an alert to "onkeydown" and checking if it is a [ctrl] key, and alerting the user if it is.
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 2:34 pm
by lauthiamkok
tasairis wrote:No. There is no way. And personally, I hate it when people try to do that.
the main reason is some people would type the email incorrectly in the first input field which happens to myself sometimes.... lol
the message is sent but cannot reach the sender for verification bcos they type the email address incorrectly...
so if I have been forced to type the email twice then I would pay more attention...

Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 2:38 pm
by lauthiamkok
omniuni wrote:
You could try binding an alert to "onkeydown" and checking if it is a [ctrl] key, and alerting the user if it is.
this requires JavaScript isn't?
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 4:55 pm
by requinix
lauthiamkok wrote:the main reason is some people would type the email incorrectly in the first input field which happens to myself sometimes.... lol
the message is sent but cannot reach the sender for verification bcos they type the email address incorrectly...
so if I have been forced to type the email twice then I would pay more attention...

There's only so far you can go to protect people from themselves. I, for one, wish there was less of this going on as it would encourage responsibility.
If they can't bother to check that their email address is correct then it's their fault.
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 5:43 pm
by omniuni
lauthiamkok wrote:omniuni wrote:
You could try binding an alert to "onkeydown" and checking if it is a [ctrl] key, and alerting the user if it is.
this requires JavaScript isn't?
Yes, I'm afraid so. You can not disable something in the browser from the server side.
Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 6:53 pm
by lauthiamkok
omniuni wrote:
Yes, I'm afraid so. You can not disable something in the browser from the server side.
i think it was a bad idea of mine to have that. it's better off doing this thing on server side only. thanks mate

Re: Disable copy/paste with php?
Posted: Mon Mar 29, 2010 6:54 pm
by lauthiamkok
tasairis wrote:
If they can't bother to check that their email address is correct then it's their fault.
yes it is true!
