可能重复:
禁用使用Javascript复制/粘贴到HTML表单
我的银行似乎已禁用复制-粘贴用户名和密码.
My bank seem to have disabled copy-paste of username and password.
它是如何完成的?它会提高安全性吗?
How is it done? Does it improve security?
您可以禁用粘贴输入,如下所示:
You can disable paste in your input as follows:
html:
<input type="text" value="" id="myInput">
javascript:
window.onload = () => {
const myInput = document.getElementById('myInput');
myInput.onpaste = e => e.preventDefault();
}
谈到安全性,我不会说这会产生任何影响.您通常会使用客户端和服务器端验证用户提交的数据.
Talking about security, I wouldn't say that this makes any impact. You would usually use client side and well as server-side validation of data submitted by the user.
这篇关于在 HTML 输入字段中禁用复制粘贴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!