[code]<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
alert(keychar)
numcheck = /\d/;
return !numcheck.test(keychar);
}
</script>
<form>
Type some text (numbers not allowed):
<input type="text" οnkeydοwn="return noNumbers(event)" />
</form>
</html>[/code]
==================================
//如果输入回车,则提交表单
[code]<input type="text" οnkeydοwn="if(event.keyCode==13)document.forms[0].submit();"/>[/code]
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
var keychar;
var numcheck;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
keychar = String.fromCharCode(keynum);
alert(keychar)
numcheck = /\d/;
return !numcheck.test(keychar);
}
</script>
<form>
Type some text (numbers not allowed):
<input type="text" οnkeydοwn="return noNumbers(event)" />
</form>
</html>[/code]
==================================
//如果输入回车,则提交表单
[code]<input type="text" οnkeydοwn="if(event.keyCode==13)document.forms[0].submit();"/>[/code]