Enter Numbers Only

Test it here:
The box above will only allow numbers to be entered. It will reject all other characters.

Here is the javascript function:
 function numbersOnly(field, event) {
  var key, keychar;

  if (window.event)
  else if (event)
   return true;

  if ((key==null) || (key==0) || (key==8) ||
   (key==9) || (key==13) || (key==27) )
   return true;
  else if ((("0123456789").indexOf(keychar) > -1))
   return true;
  else return false;

Call the function from within an input object.
<input type="text" name="serialnumber" size="10" maxlength="10"
onkeypress="return numbersOnly(this, event)">