Disable copy/paste with php?


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…

  <script src="http://code.jquery.com/jquery-latest.js"></script>


	$('#message_email').bind('paste', function(e){
		alert('Sorry, pasting is not allowed. Please type in.');
		return false;


  <div><input name="message_email" id="message_email" type="text"/></div>

Many thanks,

PHP has nothing at all to do with how the browser behaves, so you can’t do it.

However, disabling paste functionality seems a (pretty weak) workaround to a bigger problem - e.g. spam - which CAN be sorted with PHP - checking for links, verifying IP addresses against known spammers, etc.

I’m curious what is motivating you to not allow pasting.

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… :stuck_out_tongue:

Forcing people to type their email twice is annoying. You can see exactly what you typed in the field so as to correct it if you made a mistake. Also with a decent browser the browser remembers your email address so that when you start typing it the browser will display the address and you can then just click on it rather than having to type the whole thing.

The only field that needs to be duplicated is a “new password” field because that’s the only one where you can’t see what you typed to tell if you made a typo.

I generally leave any site that asks me to enter my email address twice and go to their more sensible competitor which only asks me to enter it once instead.

I agree with felgall, it is damn annoying, and if you want to do something like that, then concentrate on the repeat password field.
PHP will not allow you to control anything as far as your local user’s browser is concerned.

Hear hear!

Really? Typing your own email annoys you:nono:? I am speechless, to say the least. What the world is come to?. It is your own email we are talking about.

I for one prefer it when things that I’ve use before remember me. While web browsers can remember these things as well, it can be a nice addition for the web site to remember these things too. The only issue is deciding on the types of situations where it is appropriate.

Well actually I just type the first letter and select it from the list that pops up.

What is annoying is that some idiot has decided that they want me to do it twice just in case I forgot what letter my email address started with. The sort of people who are likely to forget what letter their email address starts with would be likely to forget where they left their brain if they ever got one.

My email address starts with an S so that’s what I’d type in the first field. My memory is good enough that when I get to the next field I can still remember it starts with an S but can’t imagine why the person who created the form could possibly think that I might have forgotten and typed the wrong letter in one of the fields. Of course if I did forget and typed the wrong letter in the first field then my email address wouldn’t be in the list to select it so I’d know even without the second email field.

It isn’t typing in my email address that is annoying. What is annoying is that some people think that by asking for my email address twice that I will be more likely to remember what letter it starts with than I will if they only ask for it once. Anyone with two brain cells ought to be able to remember that without having to be asked to enter it twice.