CODEDIGEST
Home » CodeDigest
Search
 

Technologies
 

Prevent or Disable Cut, Copy and Paste operation in ASP.Net TextBox Using jQuery
Submitted By Bala Murugan
On 11/17/2010 6:40:02 AM
Tags: ASP.Net,CodeDigest,jQuery  

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

 

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) {
                event.preventDefault();
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>   
        <b>Email </b><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br />
        <b>Confirm Email </b><asp:TextBox ID="txtConfirmEmail" runat="server"></asp:TextBox>

Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..