开发者

disable paste (control V) in IE for an input text box

Is there a way to disable the paste (control V) into a text box using javascript/jquery for IE?

I do not have access to the markup unfortunately or I would use onPaste="return false". Can it be attached with Jquery?

If it cannot be disabled at least is there a way to detect it so that when the paste event occurs just remove the text from the input text box.

<input type="text" maxlength="" size="25"开发者_开发问答 value="Enter letters here" name="TEXTBOX___97___470GCPC___31" autocomplete="off">


Try

$('input[name="TEXTBOX___97___470GCPC___31"]').bind('paste', function(){return false;})

There is no need to use jQuery though, as you could just set the onpaste handler.

var input = document.getElementsByName('TEXTBOX___97___470GCPC___31')[0];
if (input)
   input.onpaste = function(){return false;};

Note that this event may not fire on some browsers (e.g. Opera). Also, see this question: Disable Copy/Paste into HTML form using Javascript on why you should not disable pasting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜