i have two field one is emailid and another is password in my form. i want to detect that when user reenter the email and password than he should not able to copy the above. he have to write again manually.Just like google forms
我有两个字段,一个是emailid,另一个是我表单中的密码。我想发现当用户重新输入电子邮件和密码时,他不能复制上面的内容。他必须再手工写一遍。就像谷歌形式
1 个解决方案
#1
7
You could disable ctrl+v
combination and right click
as well.
您可以禁用ctrl+v组合和右键单击。
for IE, you may use;
对于IE,你可以使用;
onpaste="return false;" oncut="return false;" oncontextmenu="return false;" oncopy="return false;".
Here is a workaround for all browsers;
这里有一个针对所有浏览器的变通方案;
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;
var ctrl = (document.all) ? event.ctrlKey:e.modifiers & Event.CONTROL_MASK;
var msg = "Sorry, this functionality is disabled.";
if (document.all)
{
if (ctrl && code==86) //CTRL+V
{
alert(msg);
window.event.returnValue = false;
}
else if (ctrl && code==67) //CTRL+C (Copy)
{
alert(msg);
window.event.returnValue = false;
}
}
else {
if (ctrl==2) //CTRL key
{
alert(msg);
return false;
}
}
}
Email :<input name="email" type="text" value=""/><br/>
Password :<input name="password" type="password" value=""/><br/>
Confirm Email :<input name="email" type="text" value="" onkeydown="return noCTRL(event)"/>
Confirm Password :<input name="password" type="password" value="" onkeydown="return noCTRL(event)"/>
and I don't think user can copy password fields if input type is password
如果输入类型是密码,我认为用户不能复制密码字段
Hope this helps.
希望这个有帮助。
Note: 1. Disabling JavaScript in browser will let user do whatever he want 2. Always respect user's freedom. Keep this in your mind
注意:1。在浏览器中禁用JavaScript可以让用户做任何他想做的事情。总是尊重用户的*。记住这一点
#1
7
You could disable ctrl+v
combination and right click
as well.
您可以禁用ctrl+v组合和右键单击。
for IE, you may use;
对于IE,你可以使用;
onpaste="return false;" oncut="return false;" oncontextmenu="return false;" oncopy="return false;".
Here is a workaround for all browsers;
这里有一个针对所有浏览器的变通方案;
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;
var ctrl = (document.all) ? event.ctrlKey:e.modifiers & Event.CONTROL_MASK;
var msg = "Sorry, this functionality is disabled.";
if (document.all)
{
if (ctrl && code==86) //CTRL+V
{
alert(msg);
window.event.returnValue = false;
}
else if (ctrl && code==67) //CTRL+C (Copy)
{
alert(msg);
window.event.returnValue = false;
}
}
else {
if (ctrl==2) //CTRL key
{
alert(msg);
return false;
}
}
}
Email :<input name="email" type="text" value=""/><br/>
Password :<input name="password" type="password" value=""/><br/>
Confirm Email :<input name="email" type="text" value="" onkeydown="return noCTRL(event)"/>
Confirm Password :<input name="password" type="password" value="" onkeydown="return noCTRL(event)"/>
and I don't think user can copy password fields if input type is password
如果输入类型是密码,我认为用户不能复制密码字段
Hope this helps.
希望这个有帮助。
Note: 1. Disabling JavaScript in browser will let user do whatever he want 2. Always respect user's freedom. Keep this in your mind
注意:1。在浏览器中禁用JavaScript可以让用户做任何他想做的事情。总是尊重用户的*。记住这一点