如何防止在文本框控件中拖放文本和复制粘贴文本 [英] How to prevent a drag and drop text and Copy paste text in your textbox control

查看:107
本文介绍了如何防止在文本框控件中拖放文本和复制粘贴文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想防止复制粘贴和拖放到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).


这篇关于如何防止在文本框控件中拖放文本和复制粘贴文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆