Aolo numeros en caja de texto

Daniel
18 de Septiembre del 2003
tengo este problema quiero que en una caja de texto solo me escriba numeros y tengo esto

function solonumero(e)
{
var ascii
ascii = e.keyCode
if (ascii <= 47 || ascii >= 58)
{
alert("Solo se aceptan números")
return(false);
}
}

en la caja de texto asi lo llamo
<input type=text size=11 maxlength=10 name=busmedclave onkeypress="javascript:solonumero(event)">

pero aun asi me escribe la letra...

Khriztian
18 de Septiembre del 2003
Prueba con este ejemplo :

<html>
<head>

<script language="JavaScript">
<!--
var nav4 = window.Event ? true : false;
function acceptNum(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57));
}
//-->
</script>

</head>
<body>

<p><input type="text" name="valor" size="12" maxlength="12"
onKeyPress="return acceptNum(event)"></p>

</body>
</html>