<script language="javascript">
function myKeyDown(e){
if(window.event){//IE
var k = e.keyCode;
if ((k == 13)||(k == 9) || (k == 35) || (k == 36) || (k == 8) || (k == 46) || (k >= 48 && k <=57 )||( k >= 96 && k <= 105)||(k >= 37 && k <= 40)){
}else{
window.event.returnValue = false;
}
}else{//火狐
var k = e.which;
if ((k == 13)||(k == 9) || (k == 35) || (k == 36) || (k == 8) || (k == 46) || ( k>= 48 && k <= 57)||(k >= 96 && k <= 105)||(k >= 37 && k <= 40)){
}else{
e.preventDefault();
}
}
}
</script>
<input style="ime-mode:disabled" maxlength="10" onkeydown="myKeyDown(event);"/>
style="ime-mode:disabled" 禁止切换输入法
function myKeyDown(e){
if(window.event){//IE
var k = e.keyCode;
if ((k == 13)||(k == 9) || (k == 35) || (k == 36) || (k == 8) || (k == 46) || (k >= 48 && k <=57 )||( k >= 96 && k <= 105)||(k >= 37 && k <= 40)){
}else{
window.event.returnValue = false;
}
}else{//火狐
var k = e.which;
if ((k == 13)||(k == 9) || (k == 35) || (k == 36) || (k == 8) || (k == 46) || ( k>= 48 && k <= 57)||(k >= 96 && k <= 105)||(k >= 37 && k <= 40)){
}else{
e.preventDefault();
}
}
}
</script>
<input style="ime-mode:disabled" maxlength="10" onkeydown="myKeyDown(event);"/>
style="ime-mode:disabled" 禁止切换输入法
附上keycode表
|
2012年12月09日 02:20
不错不错!