日期:2014-05-16  浏览次数:20402 次

怎么让用户不能输入"\"这个字符啊?
我想让用户不能输入反斜杠,有没有什么好方法啊?
成功了就给分~

------解决方案--------------------
function document.onkeydown() {
if(event.keyCode==191)
{
event.keyCode =999;
event.returnValue=false;
}
}
javascript 禁用 '/ '输入
------解决方案--------------------
对像标签里加入:onKeyDown= "if(window.event.keyCode==220){return false;}; "
如: <input type= "text " name= "textfield " onKeyDown= "if(window.event.keyCode==220){return false;}; ">
------解决方案--------------------
下面的例子列出了常用的一些特殊键的ASCII码,以及Ctrl,Shift,Alt+其它键的组合方法
<html>
<head>
<script type= "text/javascript ">
function showKeyName(e)
{
var keyName;
switch(e.keyCode)
{
case 8:keyName = "[退格] ";break;
case 9:keyName = "[Tab] ";break;
case 13:keyName = "[Enter] ";break;
case 16:keyName = "[Shift] ";break;
case 17:keyName = "[Ctrl] ";break;
case 18:keyName = "[Alt] ";break;
case 19:keyName = "[PauseBreak] ";break;
case 20:keyName = "[Caps Lock] ";break;
case 27:keyName = "[Esc] ";break;
case 32:keyName = "[空格] ";break;
case 33:keyName = "[PageUp] ";break;
case 34:keyName = "[PageDown] ";break;
case 35:keyName = "[End] ";break;
case 36:keyName = "[Home] ";break;
case 37:keyName = "[方向键左] ";break;
case 38:keyName = "[方向键上] ";break;
case 39:keyName = "[方向键右] ";break;
case 40:keyName = "[方向键下] ";break;
case 45:keyName = "[Insert] ";break;
case 46:keyName = "[Delete] ";break;
case 91:keyName = "[左Win] ";break;
case 92:keyName = "[右Win] ";break;
case 93:keyName = "[快捷菜单键] ";break;
case 95:keyName = "[Sleep] ";break;
case 96:keyName = "[小键盘区0] ";break;
case 97:keyName = "[小键盘区1] ";break;
case 98:keyName = "[小键盘区2] ";break;
case 99:keyName = "[小键盘区3] ";break;
case 100:keyName = "[小键盘区4] ";break;
case 101:keyName = "[小键盘区5] ";break;
case 102:keyName = "[小键盘区6] ";break;
case 103:keyName = "[小键盘区7] ";break;
case 104:keyName = "[小键盘区8] ";break;
case 105:keyName = "[小键盘区9] ";break;
case 106:keyName = "[*] ";break;
case 107:keyName = "[+] ";break;
case 109:keyName = "[-] ";break;
case 110:keyName = "[.] ";break;
case 111:keyName = "[/] ";break;
case 112:keyName = "[F1] ";break;
case 113:keyName = "[F2] ";break;
case 114:keyName = "[F3] ";break;
case 115:keyName = "[F4] ";break;
case 116:keyName = "[F5] ";break;
case 117:keyName = "[F6] ";break;
case 118:keyName = "[F7] ";break;
case 119:keyName = "[F8] ";break;
case 120:keyName = "[F9] ";break;
case 121:keyName =