Restrict copy/cut/paste to a form field

Home » JavaScript » Restrict copy/cut/paste to a form field
Date: 2005-06-19
Link: http://javascript.devquickref.com/javascript-restict-copy-cut-paste.html

Restrict copy/cut/paste to a form field

 
    Enter password: 
    <input type="password" name="pass" id="PASSWORD" size="30" width="30" oncopy="return false" onpaste="return false" oncut="return false">
<table class="code">
    <tr>
        <td>
    Enter password: &lt;br /&gt; 
    &lt;input type="password" name="pass" id="PASSWORD" size="30" width="30" oncopy="return false" onpaste="return false" oncut="return false"&gt;
        </td>
    </tr>
</table>
 
 
Comments
author: <script language="JavaScript"> <!-- document.oncontextmenu = function() { return false; } if ( doc
date: 2009-01-04 12:34:09
title: Re: Restrict copy/cut/paste to a form field
<script language="JavaScript">
<!--
document.oncontextmenu = function()
{
 return false;
}

if ( document.layers )
{
 window.captureEvents(Event.MOUSEDOWN);

 window.onmousedown = function(e)
 {
  if ( e.target == document )
   return false;
 }
}
else
{
 document.onmousedown = function()
 {
  return false;
 }
}
// -->
</script>