Wednesday, September 18, 2013

How to disable cut, copy, paste on a textbox using jquery

First declare a textbox & then applying the following jquery method like this:

  <input type="text" name="txtName" id="txtName" />

<script type="text/javascript">
    $(document).ready(function () {
        $('#txtName').bind('cut copy paste', function (e) {
            // prevent the default operation
            e.preventDefault();
            // warn the user
            alert("Paste disabled in this textbox");
        });
    });
</script>

No comments:

Post a Comment