javascript - How do you disable typing but allow copy and paste? -


i creating webpage, , need users copy & paste textbox. can't allow typing, copy , paste. how this, regardless of technology i'm using?

there no set way this. have perform work-around here:

jsfiddle

i set maxlength of text box 0, when paste event occurs, maxlength changed high number allow paste, after paste maxlength changed 0 user can delete in there not type new.

html

<input id="text1" type="text" name="name" maxlength="0" /> 

jquery

$("#text1").bind('paste', function(e) {     $(this).attr("maxlength","1000") }); $("#text1").on("input",function(){    $(this).attr("maxlength","0")  }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -