Thursday, November 6, 2014

Disable Cut Copy Paste and Drop options in HTML and ASP.Net Using Java Script And JQuery

put below code in head tag.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var controls = $(".disable");
            controls.bind("paste", function () {
                return false;
            });
            controls.bind("drop", function () {
                return false;
            });
            controls.bind("cut", function () {
                return false;
            });
            controls.bind("copy", function () {
                return false;
            });
        });
        function disableRightClick() {
            alert("Sorry, right click is not allowed !!");
            return false;
        }
    </script>
    <style type="text/css">
        .disable {
    -moz-user-select:none;
    -webkit-user-select:none;
    user-select:none;
      }
    </style>
put below code in form tag.
<div class="disable" oncontextmenu=" return disableRightClick();"></div>

No comments:

Post a Comment