473,387 Members | 1,441 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,387 software developers and data experts.

Disabling copy option

3
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="return 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 1349
mrhoo
428 256MB
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
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....
4
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....
1
by: John | last post by:
Hi How can I disable or hide a menu item via vba? Thanks Regards
1
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
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...
2
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...
2
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
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)...
11
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
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...
0
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...

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.