www.webdeveloper.com
Results 1 to 5 of 5

Thread: How do I override paste prevention?

  1. #1
    Join Date
    Apr 2005
    Posts
    486

    How do I override paste prevention?

    e-Bay stop you pasting in phone numbers
    You have to type by hand
    It's a long story why... but it's a pain for me

    Can someone tell me how I can override the Javascript control they've put in?
    I dont need to override anything else... just this bit

    Thanks


    OM

  2. #2
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    155
    There's 2 main ways I thought of doing this: having some script execute once the window loads or having an event fire when a user tries to paste. The example below illustrates both. The only thing to keep in mind is that for the script in window.onload, onpaste will not disable pasting if it is equal to false, it needs to be equal to a function, even if that function only returns false.

    HTML Code:
    <!DOCTYPE html>
    <html>
    	<head>
    		<script type = "text/javascript">						
    			window.onload = function() {
    				document.getElementById("paste2").onpaste = noPaste;
    			}
    			
    			function noPaste() {
    				return false;
    			}
    			
    			function preventPaste(x) {
    				return false;
    			}
    		</script>
    	</head>
    	<body>
    		<form>
    			<input type = "text" placeholder = "can paste in here" />
    			<br />
    			<input type = "text" id = "paste1" onpaste = "return preventPaste(this)" />
    			<br />
    			<input type = "text" id = "paste2" />
    		</form>
    	</body>
    </html>
    Last edited by Error404; 04-13-2014 at 01:33 PM.

  3. #3
    Join Date
    Apr 2005
    Posts
    486
    thanks for the reply
    i think u may have misunderstood my question
    i am trying to paste where the website has taken action to stop pasting (for one field only)

    i googled and saw that greasemonkey on firefox is a solution with a specific script - but the link to the script doesnt exist

    let me know what u think
    thanks

  4. #4
    Join Date
    Feb 2014
    Location
    Canada
    Posts
    155
    Quote Originally Posted by OM2 View Post
    thanks for the reply
    i think u may have misunderstood my question
    i am trying to paste where the website has taken action to stop pasting (for one field only)
    So you want to edit their javascript so you can paste when they're preventing it? You could use Greasemonkey for that or you could look at their client-side source code. Personally, I wouldn't bother doing it as I'd just type it again and save myself the hassle, unless you're doing this to learn about JavaScript.

  5. #5
    Join Date
    Apr 2005
    Posts
    486
    Well, I don't want to edit their java script as such...
    I just want to disable for one field only
    They have the java script there for good reasons I imagine
    But for me it's a massive pain as I have to manually type in the field again and again

    There is supposed to be a script for grease monkey that does the job. Where I can choose to disable just one page of a specific site. That's great. Except the website doesn't seem to exist

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles