GEM-I'm a dedicated Wordpress & Squarespace developer

Disable Copy or Paste action for text box?

I have Three solutions in my mind:

First Is –>

Use ——-> oncopy=”return false” onpaste=”return false”

Name: 
<input type="textbox" id="name" oncopy="return false" onpaste="return false" ><br/>
Name:

Second is –> With Jquery ,Use e.preventDefault();

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>
$('#name').bind("cut copy paste",function(e) {
          e.preventDefault();
      });
</script>

</head> 
Name: 
<input type="textbox" id="name" >
Name:

Third is –>With Jquery , Use return false


<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

<script>

$( "#name" ).on( "copy cut paste drop", function() {
                return false;
        });
</script>

</head> 
Name: 
<input type="textbox" id="name" >
Name:
Spread the Code

GEM

GEM

You may also like...

1 Response

  1. ngtbkw says:

    Disable Copy or Paste action for text box? – GemCode
    angtbkw
    ngtbkw http://www.g5vmd7vek6q9qh2429qy2mu7k2426t42s.org/
    [url=http://www.g5vmd7vek6q9qh2429qy2mu7k2426t42s.org/]ungtbkw[/url]

Leave a Reply

Your email address will not be published. Required fields are marked *