Page 1 of 1

JavaScript to block paste

Posted: Thu Oct 20, 2005 7:00 am
by onion2k
I'm trying to find a script that can block people simply copy'n'pasting things in forms .. I've got elements for people to confirm their password and email address .. and at a client's site yesterday it became clear that at least one user was entering their email address, copying it, and pasting it into the confirmation box. Kind of makes the whole thing a bit pointless..

Is there a way to stop pasting via javascript?

Posted: Thu Oct 20, 2005 8:03 am
by feyd
There is no definitive way I am aware of.. On the newer browsers you can hook the paste event, but it only takes a few clicks to disable Javascript if someone really wants to get around it.

Although it may penalize people that type excessively fast, you could look at using a change rate test. i.e. poll the fields for their value at a ~quick rate (30ms). If the value changes significantly since the last poll (like 3-5 characters) deny the change or something...