Prevent or Disable Cut, Copy and Paste operation in ASP.Net TextBox Using jQuery

Posted by Harshitha under ASP.NET category on | Points: 40 | Views : 1001
It is required to block the cut, copy and paste operations on some of the textbox in an ASP.Net. For example, it will be better if we do not allow users to copy paste the data entered in Email and Confirm Email field in order to make the user to type themselves.

The below jQuery code will help us to do the same using preventDefault() method.

<script src="_scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#<% =txtEmail.ClientID %>,#<% =txtConfirmEmail.ClientID%>").bind("cut copy paste", function(event) {
<form id="form1" runat="server">
<b>Email </b><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br />
<b>Confirm Email </b><asp:TextBox ID="txtConfirmEmail" runat="server"></asp:TextBox>

Comments or Responses

Login to post response