jasonc Posted May 22, 2011 Share Posted May 22, 2011 I wish for my users to retype their email address instead of the copy and paste method to ensure they have typed it correctly both times. How could this be done, would it be Javascript ? Quote Link to comment https://forums.phpfreaks.com/topic/237098-prevent-user-using-ctrl-v-to-paste/ Share on other sites More sharing options...
sunfighter Posted May 23, 2011 Share Posted May 23, 2011 I found this on the web. It disables a little more than ctrl-v: function disableCtrlModifer(evt) { var disabled = {a:0, c:0, x:0, v:0}; var ctrlMod = (window.event)? window.event.ctrlKey : evt.ctrlKey; var key = (window.event)? window.event.keyCode : evt.which; key = String.fromCharCode(key).toLowerCase(); return (ctrlMod && (key in disabled))? false : true; } Call it this way: <input type="text" name="mytext" onkeypress="return disableCtrlModifer(event);" onkeydown="return disableCtrlModifer(event);" /> Quote Link to comment https://forums.phpfreaks.com/topic/237098-prevent-user-using-ctrl-v-to-paste/#findComment-1218901 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.