• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Retrict copy from a text field

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 you suggest me some method in which this can be achieved
 
Albin Jose
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the following methods , they work for IE but not for mozilla,

1.<body ondragstart="return false" onselectstart="return false">


2.
function preventCopyPaste() {
var key = String.fromCharCode(event.keyCode).toLowerCase();
if ((event.ctrlKey && (key == "c" || key == "v")) ||
(event.shiftKey && event.keyCode==45)) {
event.returnValue = false;
}
}
function preventRightClick(){
var rightClick=false;
if(event.which) rightClick=(event.which==3);
if(event.button) rightClick=(event.button==2);
if(rightClick) alert("Right click restricted");
}

But this doesn work for mozilla, any other option,

Thanks ,
Albin.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cannot give you much help. Your solution seems very Windows centric, but maybe that is okay. I mostly wanted to point out that you would also have to check for Ctrl+Insert and Shift+Insert combinations as well. My vote is that this is not a very user friendly interface.

- Brent
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It does not work in Mozilla because you are not detecting keypress events correctly. Just type in JavaScript keycode into Google and you should find examples on correct detection.

Eric
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try this for a while may be it should work


function preventPaste(theTextArea){
theTextArea.onpaste = function (){
return false;
}
}
 
Albin Jose
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks all of you
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic