Preventing Users From Copying Text From and Pasting It Into TextBoxes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Many websites that support user accounts require users to enter an email address as part of the registration process. This email address is then used as the primary communicationchannel with the user. For instance, if the user forgets her password a new one can be generated and emailed to the address on file. But what if, when registering, a userenters an incorrect email address? Perhaps the user meant to enter me@example.com, but accidentally transposed the first two letters, entering em@example.com. How can such typos be prevented?

The only foolproof way to ensure that the users entered email address is valid is to send them a validation email upon registering that includes a link that, when visited,activates their account. (This technique is discussed in detail in Examining ASP.NETs Membership, Roles, and Profile - Part 11.) The downside to using a validation email is that it adds one more step to the registration process, which will cause some people to bail out on theregistration process. A simpler approach to lessening email entry errors is to have the user enter their email address twice, just like how most registration forms promptusers to enter their password twice. In fact, you may have seen registration pages that do just this. However, when I encounter such a registration page I usually avoidentering the email address twice, but instead enter it once and then copy and paste it from the first textbox into the second. This behavior circumvents the purpose of the two textboxes - any typo entered into the first textbox will be copied into the second.

Using a bit of JavaScript it is possible to prevent most users from copying text from one textbox and pasting it into another, thereby requiring the user to type theiremail address into both textboxes. This article shows how to disable cut and paste between textboxes on a web page using the free jQuery library. Read on to learn more!
Read More >



More...
 
Back
Top