I have two text boxes in asp. I want to avoid cut & paste of data from one text box to another textbox. I know I can do it with javascript, but I don’t kno whow to do it.
@netbuddyJun 25.2006 — #you take the reference to the one box and make the reference in the other box equal to it. it would be done something like this...
if you have 1 form with 2 text boxes, one named copyofboxname & another textboxnametocopy, the copyofboxname will be given the content of the other text box.
the html would look like this
<form>
<textearea name='textboxnametocopy'></textarea>
<textearea name='copyofboxname'></textarea>
</form>
if you have 2 text areas and they are in different forms...
@phpnoviceJun 25.2006 — #If you mean you wish to [B][I][U]prevent[/U][/I][/B] cut-n-paste operations... I don't know why you'd want to do that. But, the following works perfectly in IE to prevent every method of selecting text that I could think of -- while still allowing the mouse to click into the textbox for normal data entry: window.onload = function() { var obj = document.forms["myFormName"].elements["myTextboxName1"]; obj.onbeforecut = function() { return false }; obj.onbeforepaste = function() { return false }; obj.oncontrolselect = function() { return false }; obj.oncut = function() { return false }; obj.ondblclick = function() { return false }; obj.onmousedown = function() { return false }; obj.onpaste = function() { return false }; obj.onselect = function() { return false }; obj.onselectstart = function() { return false }; return true; } Of these, only the [b]onmousedown[/b] and [b]ondblclick[/b] events work to prevent selections via mouse in Mozilla. However, cancelling the [b]onmousedown[/b] event in Mozilla also prevents clicking into the textbox with the mouse. Not good.
@felgallJun 25.2006 — #And disabling Javascript (temporarily) would re-enable the cut and past capability making the entire code pointless. You can't stop your visitors doing what they want when they are on your page- you need to work around whatever they decide to do.