如何防止在文本框控件中拖放文本和复制粘贴文本
大家好,
我想防止复制粘贴和拖放到HTML文本框.
有可能吗?
如果是,那怎么办?
谢谢与问候,
Arvind Thakur
Hi Guys,
I want to prevent copy-paste and drag-n-drop to my html textbox.
Is it possible?
If yes then how?
Thanks & regards,
Arvind Thakur
个人而言,我希望您没有.
我经常使用复制粘贴来输入密码,尤其是在设置密码时,因此我知道加密存储中的版本与输入的数据相同.禁用它使我很烦-我的ISP做到了,所以我必须手动输入它.对于某些残疾人来说,使用他们的计算机也将变得更加困难.
不过,它仍然适用于大多数浏览器:
Personally, I would rather you didn''t.
I frequently use copy-paste to enter passwords, particularly when I am setting them up, so I know the version in my encrypted store is the same as the entered data. Disabling that annoys me - my ISP does it so I have to manually type it in. It would also be harder for some disabled people to use their computer.
Still, it works for most browsers:
<input type="text" name="TextBox1" onPaste="return false" />
禁用文本框中的粘贴-它不是标准内容的一部分,但即使不是所有浏览器,它也可以在大多数浏览器中使用,即使VS说它不存在.
您不能禁用文本框上的拖放-按文本框AFAIK,但要查看表单的onDragDrop属性.我不知道它是否有效(在Chrome中,它会在窗口中打开文件).
Disables paste in a textbox - it is not part of the standard but it should work in most if not all browsers, even if VS says it doesn''t exist.
You can''t disable drag-drop on a textbox - by textbox basis AFAIK, but look at the onDragDrop property of the form. I have no idea if it works (in Chrome it opens the file in the window).