Need to prevent copy paste in a textbox using jquery. How to implement it?
<table>
<tr>
<h:inputlabel value="Actual"></h:inputlabel>
<td>
<h:inputtext id="Actual" styleClass="input-tex" value="#bean.customer"></h:inputtext>
<td>
</tr>
<table>
By using an on() method: It is a built-in method in jQuery. With the help of this method, we will able to disabled the cut, copy, paste and right-click option. // Disables ctrl+v, ctrl+x, ctrl+c.
You can use jquery for this: $('body'). bind('copy paste',function(e) { e. preventDefault(); return false; });
You can disable cut, copy, and paste using the oncut, oncopy, and onpaste event attributes with the target HTML elements. If you want to disable cut, copy, and paste for the complete web page, you need to use these event attributes with the body tag.
Here to go: Disable Cut, Copy and Paste function for textbox using jQuery
$(document).ready(function(){
$('#Actual').bind("cut copy paste",function(e) {
e.preventDefault();
});
});
Note: Opera didn't support cut, copy and paste events before version 12.10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With