prueva con algo asi:
Código HTML:
<script language="javascript">
function validarNum(event, element, _float){
event = event || window.event;
var charCode = event.which || event.keyCode;
if (charCode == 8 || charCode == 13 || (_float ? (element.value.indexOf('.') == -1 ? charCode == 46 : false) : false))
return true;
else if ((charCode < 48) || (charCode > 57))
return false;
return true;
}
</script>
...
Código HTML:
<!-- no decimales -->
<input type="text" onkeypress="validarNum(event, this)"/>
<!-- con decimales -->
<input type="text" onkeypress="validarNum(event, this, true)"/>