473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Prevent user copy + pasting from one field to next

Hi all,

I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?

If it were up to me, I'd use just one box for the email address - but
it isn't, so it has to be done twice.

Thanks

M

Sep 14 '06 #1
17 5438

em******@gmail.com wrote:
Hi all,

I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?
The only way to prevent copy & paste to a second field is to not have a
second field. :-)

--
Rob

Sep 14 '06 #2
The only way to prevent copy & paste to a second field is to not have a
second field. :-)
:) mm, I realise it's a pretty dumb question - but is there any
javascript solution.

Sep 14 '06 #3
rf
em******@gmail.com wrote
>
I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.
Hmmm. This user is filling out this form in anticipation of receiving emails
from you?

If they do it incorrectly, by either copy/pasting drag/dropping an incorrect
address or even typing an incorrect address twice then is it not *their*
problem? Even if you do everything in your power to protect yourself against
fools then very shortly a better fool will come along :-)

--
Richard.
Sep 14 '06 #4

rf wrote:
Hmmm. This user is filling out this form in anticipation of receiving emails
from you?
yes, it's a sign up process
If they do it incorrectly, by either copy/pasting drag/dropping an incorrect
address or even typing an incorrect address twice then is it not *their*
problem? Even if you do everything in your power to protect yourself against
fools then very shortly a better fool will come along :-)
very much agreed, but it is a company decision to use 2 boxes and not
mine!

I was hoping there was a javascript solution to this - if anyone can
point in the direction of what methods i might use etc?

Sep 14 '06 #5
rf
em******@gmail.com
>
rf wrote:
>Hmmm. This user is filling out this form in anticipation of receiving
emails
from you?

yes, it's a sign up process
Thought so :-)
>If they do it incorrectly, by either copy/pasting drag/dropping an
incorrect
address or even typing an incorrect address twice then is it not *their*
problem? Even if you do everything in your power to protect yourself
against
fools then very shortly a better fool will come along :-)

very much agreed, but it is a company decision to use 2 boxes and not
mine!
So, look around. Many sign up processes uses two boxes. None of these (that
I have seen) prohibit copy/paste etc. Why should yours? Is this a "boss
directive" that you disallow copy/paste etc? If so then you should advise
your boss accordingly.

Or are you inventing a problem that everybody else has simply ignored? It is
IMHO not your problem. If somebody willingly duplicates an incorrect address
then that person is not really using your sign up process correctly. I for
one *like* the two boxes, it checks for my typos and *I* never copy/paste.
What would be the point?
I was hoping there was a javascript solution to this
I really don't think there is one.
- if anyone can
point in the direction of what methods i might use etc?
Carrying on from my previous comments, if you can stop every browser from
allowing this copy/paste etc in all its variations then the day after
tomorrow some browser will provide a different method of duplicating the
content of those boxes.

Once again, if your user stuffs up their sign-up process it is IMHO that
users fault, not yours.

I run several opt-in email lists. If a user signs up with an incorrect email
address and it bounces just once then they are out.

--
Richard.

Sep 14 '06 #6

rf wrote:
So, look around. Many sign up processes uses two boxes. None of these (that
I have seen) prohibit copy/paste etc. Why should yours? Is this a "boss
directive" that you disallow copy/paste etc? If so then you should advise
your boss accordingly.
I guess I'm going to have to!
Or are you inventing a problem that everybody else has simply ignored?
Yeah, it isn't really a problem at all - not in the grand scheme of
forms.
Once again, if your user stuffs up their sign-up process it is IMHO that
users fault, not yours.
Ok, brilliant Richard. Thanks for all your information.

Sep 14 '06 #7

rf wrote:
em******@gmail.com
So, look around. Many sign up processes uses two boxes. None of these (that
I have seen) prohibit copy/paste etc. Why should yours?
Clearly you don't get around much. More and more sites attempt to
prevent pasting when entering important information twice. Travel
billing, banks, and even state DMV's asking for vehicle info, they all
do it.
I was hoping there was a javascript solution to this
Google for the "onbeforepaste" event, at least for IE users.

Cheers - Kev

Sep 14 '06 #8

Kevin Darling wrote:
rf wrote:
em******@gmail.com
So, look around. Many sign up processes uses two boxes. None of these (that
I have seen) prohibit copy/paste etc. Why should yours?

Clearly you don't get around much.
Actually, that was a bit harsh of me, although you were really giving
the OP grief :-). Perhaps you never noticed all the sites that do
this, because you use a browser that doesn't allow stopping a paste.

In any case, it's a very smart move, especially on sites where you have
to enter long series of numbers. Entering a credit card number comes
to mind.

Cheers - Kev

Sep 14 '06 #9

Kevin Darling wrote:
Google for the "onbeforepaste" event, at least for IE users.
Thanks, Kevin. I'll probably try implementing it for IE users and
it'll just be open for everyone else.

Sep 14 '06 #10

em******@gmail.com написав:
Hi all,

I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?

If it were up to me, I'd use just one box for the email address - but
it isn't, so it has to be done twice.

Thanks

M
In IE you just need to handle onPaste or/and onCopy event.
In any modern browser you can handle onKeyUp event and if user tries to
push something except alphanumerals and punctuation just return false.

Val

Sep 14 '06 #11
JRS: In article <11*********************@m73g2000cwd.googlegroups. com>,
dated Thu, 14 Sep 2006 03:34:11 remote, seen in
news:comp.lang.javascript, em******@gmail.com posted :
>
I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?
It's too late for me to test this tonight, but how about using one of
the onXXXX operations to examine the timing of the entries?

Needs to do both, unless you force entering the first one first.

Even a trained typist cannot type an entry as fast as copy'n'paste
enters it.

Anything in javascript may be defeated by using a forged page; but you
are presumably considering only moderately co-operative clients.

Thought : can onSubmit send a checksum of body innerHTML - probably -
execute document.write(document.body.innerHTML) in my js-quick.htm!

It's a good idea to read the newsgroup and its FAQ.
--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Sep 14 '06 #12
Dr John Stockton said the following on 9/14/2006 6:46 PM:
JRS: In article <11*********************@m73g2000cwd.googlegroups. com>,
dated Thu, 14 Sep 2006 03:34:11 remote, seen in
news:comp.lang.javascript, em******@gmail.com posted :
>I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?

It's too late for me to test this tonight, but how about using one of
the onXXXX operations to examine the timing of the entries?

Needs to do both, unless you force entering the first one first.

Even a trained typist cannot type an entry as fast as copy'n'paste
enters it.
That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formID.field1Name.value="em**********@som ewhere.com";
document.formID.field2Name.value="em**********@som ewhere.com";
document.formID.submit();

From being executed in the address bar.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Sep 15 '06 #13
Randy Webb wrote on 15 sep 2006 in comp.lang.javascript:
That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formID.field1Name.value="em**********@som ewhere.com";
document.formID.field2Name.value="em**********@som ewhere.com";
document.formID.submit();

From being executed in the address bar.
This one can [prevent the effect]:

<form onsubmit='return false'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 15 '06 #14
Evertjan. said the following on 9/15/2006 3:14 AM:
Randy Webb wrote on 15 sep 2006 in comp.lang.javascript:
>That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formID.field1Name.value="em**********@so mewhere.com";
document.formID.field2Name.value="em**********@so mewhere.com";
document.formID.submit();

From being executed in the address bar.

This one can [prevent the effect]:

<form onsubmit='return false'>
You may want to test that a little more. formRef.submit() doesn't
trigger the onsubmit event handler:

<form onsubmit="alert('I got fired');return false" target="_blank">
<input type="button" onclick="this.form.submit()"
value="Submit via Script">
<input type="submit" value="Submit without script">
</form>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 15 '06 #15
Randy Webb wrote on 15 sep 2006 in comp.lang.javascript:
You may want to test that a little more. formRef.submit() doesn't
trigger the onsubmit event handler:

<form onsubmit="alert('I got fired');return false" target="_blank">
<input type="button" onclick="this.form.submit()"
value="Submit via Script">
<input type="submit" value="Submit without script">
</form>
;-{

You got fired for submitting the truth to me like that, Randy!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sep 15 '06 #16
em******@gmail.com wrote:
I have a form where we would like the user to input their email address
twice, to ensure they've typed it correctly, as is found on most
sign-ups

I'm looking for a solution to the problem where a user (and me it has
to be said) just either highlights the email address with their mouse
(or Ctrl-A) and then Ctrl-C, Ctrl-P (or right-click copy, right-click
paste) into the next field down.

How would I go about this in JavaScript, or is there another solution?

If it were up to me, I'd use just one box for the email address - but
it isn't, so it has to be done twice.
Just a thought, but perhaps onfocus you could assign the current length
of the field and setup an onkeyup check for length changes 1
if the change was only but one character you update the stored length
if it's greater than 1 , do your enforcement thing.
Sep 15 '06 #17
JRS: In article <Ha******************************@comcast.com>, dated
Thu, 14 Sep 2006 21:09:12 remote, seen in news:comp.lang.javascript,
Randy Webb <Hi************@aol.composted :
>Dr John Stockton said the following on 9/14/2006 6:46 PM:
>It's too late for me to test this tonight, but how about using one of
the onXXXX operations to examine the timing of the entries?

Needs to do both, unless you force entering the first one first.

Even a trained typist cannot type an entry as fast as copy'n'paste
enters it.

That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formID.field1Name.value="em**********@so mewhere.com";
document.formID.field2Name.value="em**********@so mewhere.com";
document.formID.submit();

From being executed in the address bar.
Granted; and one could probably edit the page locally to circumvent any
checks.

But the OP seems to be trying to inhibit naive users from not benefiting
from the double-typed input check - and your code does have double
input.

javascript: with (document.formID) {
field1Name.value = field2Name.value = "em**********@somewhere.com" ;
submit() }

(untested) seems a more efficient cheat.

But the OP only needs to have a hidden field containing the results of
the timing tests ...
>--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Oversize sigs used to be - they seem to be coming back here.

--
John Stockton, Surrey, UK. ??*@merlyn.demon.co.uk Turnpike v4.00 MIME
Prof Timo Salmi's Usenet Q&A <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqn.zip>
TS FAQs via : http://www.uwasa.fi/~ts/http/ : tsfaq.html quote margin &c.
My page <URL:http://www.merlyn.demon.co.uk/news-use.htmon usage of News.
Sep 15 '06 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: The Fox | last post by:
How to prevent user to add web reference to my web services? Can I add password to web services so that only the users who know the password can add a web reference? Thanks in advance.
1
by: User | last post by:
Hi, Are there ways to let browser forget about the previous submitted form data? Or prevent user from pressing F5 to submit the same form again Or prevent user from presising back on the...
3
by: elainenguyen | last post by:
I want to add a new record and then copy the field DCDate over to the new record, but when I click on the command button it only adds a new record, but didn't copy the DCDate over. Can any body help?...
4
neo008
by: neo008 | last post by:
Hi All, Can I prevent user to press cross button? I want to disable all three buttons for minimize, maximize and close for parent as well as child window. Is it possible? I'm using VB6. ...
4
by: Luqman | last post by:
How can I Prevent user from accessing any page directly without Login ? User should not be able to by pass the Login screen by typing the Url of any page directly. I am using ASP.Net 2.0 with...
5
by: alvintiow | last post by:
Hi, I intend to use barcode for input and prevent user to modify the barcode they scan, user are not allow to input the barcode number by keyboard. Please advise how to do this. Thanks.
0
by: helveticus | last post by:
I have a master/details configuration that includes multiple user controls. The details page is configured to cache data via VaryByCustom. This works fine. One of the user controls contains an...
0
by: Appyks | last post by:
How Do I prevent User from Locking the System? Obviously I can set following Windows registry value But it doesn’t serve my propose "DisableLockWorkstation"=dword:00000001 I need...
0
by: Roger Davies | last post by:
I have a Userform in VBA 2007 Excel on which I have several textboxes and a listbox. I am able to initiate the drag and drop but cannot work out how to prevent user from dropping the data into the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.