禁用文本框粘贴功能

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
<script type="text/javascript">
//not IE is required
function fncKeyStop(evt)
{
    if(!window.event)
    {
        var keycode = evt.keyCode; 
        var key = String.fromCharCode(keycode).toLowerCase();
        if(evt.ctrlKey && key == "v")
        {
          evt.preventDefault(); 
          evt.stopPropagation();
        }
    }
}
</script>
<input type="text" onkeydown="fncKeyStop(event)" onpaste="return false" oncontextmenu = "return false;" />
</body>
</html>

 

posted on 2012-05-29 23:01  refactor  阅读(1083)  评论(0编辑  收藏  举报

导航