JQuery to Block or Disable Cut Copy Paste operation in ASP.Net TextBox C# VB.Net

To ensure data consistency sometimes we need to block or disable Cut Copy & Paste operation in Asp.Net TextBoxes. Here in this Article I will explain “How we can protect or disable Cut Copy & Paste Operation from Client side using JQuery“. If you look at real time example you will found a lot of operation where blocking the Cut Copy & Paste operation is highly required. Such as confirm email address or confirm password. The below example will demonstrate how to confirm Password process by forcing the user to retype the password.

Objective/Outcome:
JQuery to Block or Disable Cut Copy Paste operation in ASP.Net TextBox Csharp VB.Net

To complete the Example Use the Below HTML Markup:

<table>
<tr><td>Password: </td><td><asp:TextBox ID="txtPassword" runat="server"></asp:TextBox></td></tr>
<tr><td> Confirm Password: </td><td><asp:TextBox ID="txtConfirmPassword" runat="server"></asp:TextBox></td></tr>
</table>

JQuery Code Example to Block or Disable Cut Copy Paste operation:

<script type="text/javascript">
    $(document).ready(function () {
        $("#<% =txtPassword.ClientID %>,#<% =txtConfirmPassword.ClientID%>").bind("cut copy paste", function (event) {
            return false;
        });
    });  
</script>

Download Code Example C#        Download Code Example VB.Net

Posted in .Net, Asp.net, C#, Client, JQuery, VB.Net

Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code
     
 

*