Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

preventing copy paste using jquery

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>
like image 941
Ramya Avatar asked Mar 21 '13 05:03

Ramya


People also ask

How can we avoid copy paste in TextBox using jQuery?

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.

How do I restrict copy and paste in JavaScript?

You can use jquery for this: $('body'). bind('copy paste',function(e) { e. preventDefault(); return false; });

How do I restrict copy and paste in HTML?

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.


1 Answers

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

like image 156
Vishal Suthar Avatar answered Oct 13 '22 10:10

Vishal Suthar