如何顯示文本框中的高位字母,低位字母,刪除,退格和禁用空格鍵?如何在javascript中刪除,退格並禁用空格鍵?
<html>
<head>
<script type="text/javascript">
function foo(e) {
var allow=' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_'
var k;
k=document.all?parseInt(e.keyCode): parseInt(e.which);
return (allow.indexOf(String.fromCharCode(k))!=-1);
}
</script>
</head>
<body>
<input type="text" onKeyPress="return foo(event)" />
</body>
</html>
請幫我謝謝...
Duplicate:http://stackoverflow.com/questions/14236873/disable-spaces-in-input-and-allow-back-arrow – rags