<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if(keynum==13)
{
alert(document.getElementById("keyWord").value);
return false;
}
}
</script>
<form>
Type some text (numbers not allowed):
<input id="keyWord" name="keyWord" type="text" onkeydown="return noNumbers(event)" />
</form>
</html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if(keynum==13)
{
alert(document.getElementById("keyWord").value);
return false;
}
}
</script>
<form>
Type some text (numbers not allowed):
<input id="keyWord" name="keyWord" type="text" onkeydown="return noNumbers(event)" />
</form>
</html>
以下方法是其他版本 大家可以试下
<script type="text/javascript">
document.onkeydown = function(e){
if(!e) e = window.event;//火狐中是 window.event
if((e.keyCode || e.which) == 13){
document.getElementByIdx_x_x("auto").click();
}
}
</script>
document.onkeydown = function(e){
if(!e) e = window.event;//火狐中是 window.event
if((e.keyCode || e.which) == 13){
document.getElementByIdx_x_x("auto").click();
}
}
</script>