![](/img/trans.png)
[英]How to prevent user from copy-pasting text with invalid characters into input text field immediately on copy-paste action?
[英]Disable Copy-Paste from the Text Editor
@if (Model.CanMaintainNcrLineManagement) { <tr> <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionValue", @style = "height:520px" })</td> </tr> } else { <tr class="read-only-editor"> <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionReadOnly", @style = "height:520px" })</td> </tr> }
我想从文本编辑器框中禁用复制粘贴选项。 我在下面的两个代码中都使用过它来禁用它,但是它不起作用。 请给我一些解决方案
$('body').bind('copy paste', function(e) { e.preventDefault(); return false; });
<body oncopy="return false" oncut="return false" onpaste="return false">
更改代码,文本编辑器必须在body标签内,并且将阻止所有body标签内。
<body oncopy="return false" oncut="return false" onpaste="return false">
至
<body onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false">
我在Chrome 66.0.3359.181,IE 11和FireFox 59.0.3中对此进行了测试,它禁用了复制和粘贴到正文或输入中的任何内容的功能。
$('body').bind('copy paste', function (e) { e.preventDefault(); return false; });
<body oncopy="return false" oncut="return false" onpaste="return false">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.