473,761 Members | 10,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
17 5483

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************ *********@m73g2 000cwd.googlegr oups.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.i nnerHTML) 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.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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************ *********@m73g2 000cwd.googlegr oups.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.val ue="em********* *@somewhere.com ";
document.formID .field2Name.val ue="em********* *@somewhere.com ";
document.formID .submit();

From being executed in the address bar.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript 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.javas cript:
That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formID .field1Name.val ue="em********* *@somewhere.com ";
document.formID .field2Name.val ue="em********* *@somewhere.com ";
document.formID .submit();

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

<form onsubmit='retur n 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.javas cript:
>That is very true. But, none of the onXXX can stop this scenario:

javascript:
document.formI D.field1Name.va lue="em******** **@somewhere.co m";
document.formI D.field2Name.va lue="em******** **@somewhere.co m";
document.formI D.submit();

From being executed in the address bar.

This one can [prevent the effect]:

<form onsubmit='retur n 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.f orm.submit()"
value="Submit via Script">
<input type="submit" value="Submit without script">
</form>

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript 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.javas cript:
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.f orm.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.formI D.field1Name.va lue="em******** **@somewhere.co m";
document.formI D.field2Name.va lue="em******** **@somewhere.co m";
document.formI D.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.formI D) {
field1Name.valu e = field2Name.valu e = "em**********@s omewhere.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.java script 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.demo n.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.demo n.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
2692
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
5731
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 browser? Please advise.
3
2043
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? here is my code. Private Sub cmdAddNew_Click() DoCmd.GoToRecord , , acNewRec !! = Me.txtDCDate !!.SetFocus End sub
4
1761
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. Can somebody help in this.
4
6660
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 Visual Studio 2005. Best Regards, Luqman
5
21103
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
1460
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 image button. With caching turned on, the control remains "lame" since the control is only dynamically generated during the first access. My understanding is that page caching directive causes all page user controls to be implicitly cached as...
0
1336
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 something as the code follows in here using System;
0
989
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 wrong textboxes. I have searched the net but cannot find the answer to what must be a common problem. Can anyone help? - Please!!
0
9521
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10107
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9900
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5214
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5361
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3863
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3442
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.