אתה יכול למשל לבצע
בדיקת קלט על כל תו שמכניס המשתמש
ולוודא באמצעות הפונקציה isNaN
שמדובר רק בספרות
הנה דוגמא
function checkdata()
{
var val = document.getElementById("input").value;
if(isNaN(val))
{
alert("numbers only!");
document.getElementById("input").value = " ";
}
}
<body>
<input id = "input" type="text" onkeypress = "checkdata()"/>
</body>