禁用文本框的复制或粘贴操作? [英] Disable Copy or Paste action for text box?

查看:108
本文介绍了禁用文本框的复制或粘贴操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,并且我想防止用户从第一个(电子邮件)文本框中复制值并将其粘贴到第二个(confirmEmail)文本框中.

I have two textboxes, and I want to prevent user from copying the value from the first (email) textbox and pasting it in the second (confirmEmail) textbox.

Email: <input type="textbox" id="email"><br/>
Confirm Email:    <input type="textbox" id="confirmEmail">

我有两种解决方案:

  1. 防止通过电子邮件文本框执行复制操作,或者
  2. 防止从confirmEmail文本框中粘贴操作.

关于如何做到这一点的任何想法?

Any idea about how to do it?

http://jsfiddle.net/S22ew/

推荐答案

检查此小提琴小提琴

 $('#email').bind("cut copy paste",function(e) {
     e.preventDefault();
 });

您需要绑定剪切,复制粘贴时应执行的操作.您可以防止操作的默认行为. 您可以在此处

You need to bind What should be done on cut,copy paste.You prevent default behavior of the action. You can find detailed explanation here

这篇关于禁用文本框的复制或粘贴操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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