473,836 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling copy option

3 New Member
Hi,
I have a form in which i have two text boxes one for entering email and the other for verify email (to make sure the user entered the correct email id we are asking to enter the same email id twice),I need to restrict copy feature in both the fields (that is the user should not be able to copy text data from the email and confirm email text boxes) , are there any properties for text box using which i can do this or should i try using java script,I tried using some key press functions but it din work , can u suggest me some method in which this can be achieved.

I want it to work in both IE and Mozilla

I tried certain stuff which works in ie but not in mozilla .
can some one help??

1.[HTML]<body ondragstart="re turn false" onselectstart=" return false">[/HTML]

2.
Expand|Select|Wrap|Line Numbers
  1. function preventCopyPaste() {
  2.   var key = String.fromCharCode(event.keyCode).toLowerCase();
  3.   if ((event.ctrlKey && (key == "c" || key == "v")) ||
  4.     (event.shiftKey && event.keyCode==45)) {
  5.     event.returnValue = false;
  6.   }
  7. }
  8. function preventRightClick(){
  9.  var rightClick=false;
  10.  if(event.which) rightClick=(event.which==3);
  11.  if(event.button) rightClick=(event.button==2);
  12.  if(rightClick) alert("Right click restricted");
  13. }
But this doesn work for mozilla, any other option,

Thanks ,
Albin.
Mar 13 '08 #1
1 1372
mrhoo
428 Contributor
Clear the value and the defaultValue for both inputs when the first box gets focus.

When the second box gets focus, check the value in the first, make the first box readOnly, and make the defaultValue of the second box the first character from the first box.

With each keypress, match the input's value against it's default value.
If you pasted more than one character, it won't match.
If it matches, add the next character from the first text to the defaultValue of the second. If one letter at a time is correctly typed in, the defaultValue will match the input value on each keypress.

On blur or onchange, validate that the defaultValue matches the text in the second input, or notify the user that he must retype both fields, remove the readOnly and focus on the first to clear the values.
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1889
by: Fluffy Convict | last post by:
I have found a workaround to disable certain options in an option list: var p = document.forms.elements; p.selectedIndex=-1; This works perfectly in IE - the selectedIndex becomes unclickable. It does, however, not work in FireFox. Does any body have clue why not? Any help would be greatly appreciated :)
4
2614
by: Old Lady | last post by:
Hi, I need help! I have a SELECT/OPTION list. My goal is to have a TEXT input field in a form that is normally disabled, but it should become enabled when the user select one predefined OPTION. If the user change idea and select another OPTION, the TEXT input field should be disabled again. I hope I'm understandable. Sorry for my bad English.
1
1450
by: John | last post by:
Hi How can I disable or hide a menu item via vba? Thanks Regards
1
1120
by: Kuups | last post by:
Hi! I have a question is there any way of disabling the Copy, Paste, Delete ? of a Windows Control Tex Box Right Click Property during runtime ? Thanks!
12
2282
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
2
9582
by: Kapil Jain | last post by:
Dear All, I would like to disable back and forward button + Refresh button. Please help in doing this. I want this because i am displaying data from mysql database and on back and forward button complete logic get failed. Also i would like disable save as option + copy & select all option. Please urgently help me.
2
3368
by: Ravindra | last post by:
Hi all I want to disable the print screen option for my web page. can anyone help to solve this problem.It is urgent.please regards ravindra
1
2815
by: kebabkongen | last post by:
Hi, I'm working on a JavaScript that is enabling / disabling a select element according to whether a checkbox is selected or not. This works fine in Firefox, but in Internet Explorer (v 6.0.2900) it appears wierd: When I disable the selevt element in IE, it continues to appear as enabled (falsely) until I try changing it. When I click on it, updates itself as grey as to indicate that it is disabled.
11
1697
by: Tim Streater | last post by:
Am I right in thinking that while I can disable a select, I can't disable the <option>s within the select? I think this is the case but would like to be sure. Thanks, -- tim
0
9672
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10854
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...
0
10559
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10260
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
9388
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7794
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6981
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
5652
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...
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.