Friday, November 29, 2013

How to Disable Cut, Copy and Paste in Text Box using JavaScript.

Just Copy and Paste the Code in .aspx page :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tans.aspx.cs" Inherits="tans" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title> Disable Cut, Copy and Paste in Text Box using JavaScript</title>

<script type="text/javascript">
    $(document).ready(function() {
    $('#TextBox2').bind('cut copy paste', function(e) {
            e.preventDefault(); //disable cut,copy,paste
        });
    });
</script>
</head>
<body>
    <form id="form1" runat="server">
   <div>
   <asp:TextBox ID="TextBox2" runat="server" oncut="return false;" oncopy="return false;" onpaste="return false;"></asp:TextBox>

</div>
</form>
</body>

</html>


If you enjoy this post then please share.

No comments:

Post a Comment