http://feeds.feedburner.com/SpendYourTimeHere-Once

Current Affiares

Friday, July 20, 2012

How to disable copy and paste from javascript in textfield?

<head>
        <script language="javascript">
            function DisableRightClick(event)
            {
                //For mouse right click
                if (event.button==2)
                {
                    alert("Right Clicking not allowed!");
                }
            }
            function DisableCtrlKey(e)
            {
                var code = (document.all) ? event.keyCode:e.which;
                var message = "Ctrl key functionality is disabled!";
                // look for CTRL key press
                if (parseInt(code)==17)
                {
                    alert(message);
                    window.event.returnValue = false;
                }
            }
        </script>
</head>

<body>
  <h:inputText  onmousedown="DisableRightClick(event)" onkeydown="return DisableCtrlKey(event)" /> 
</body>

No comments:

Post a Comment

My Blog List

Popular Posts

All Rights Reserved To SYTHONCE. Ethereal theme. Powered by Blogger.