Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Copy, Paste into HTML form using Php

Tags:

php

I want to prevent people from pasting password in login form. Is it possible by PHP to disable the ability to paste into input fields.

like image 243
MI Sabic Avatar asked Dec 30 '25 13:12

MI Sabic


2 Answers

You can simply do this with HTML by adding some properties to input.

I don't know why you want to use PHP for this.

<input type="test" onCopy="return false" onDrag="return false" onDrop="return false" onPaste="return false"/>
like image 173
Manwal Avatar answered Jan 01 '26 03:01

Manwal


Use below code HTML

<input type="password" id="pwd">

Jquery 

 $('#pwd').bind("cut copy paste",function(e) {
          e.preventDefault();
      });
like image 29
Mahadeva Prasad Avatar answered Jan 01 '26 05:01

Mahadeva Prasad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!