Hola, cucox.
Usa este código:
Código PHP:
<html>
<head>
<script>
function validar(e) {
tecla=(document.all) ? e.keyCode : e.which;
if(tecla<48 || tecla>57)
return false;
}
</script>
</head>
<body>
<input type="text" onkeypress="return validar(event)" />
</body>
</html>
Saludos,