var input = document.getElementById("MyInput");
var handler = function ( event ) {
event = event || window.event;
return event.keyCode > 47 && event.keyCode < 58;
}
if ( input.addEventListener ) {
input.addEventListener("keypress", handler, false);
} else if ( input.attachEvent ) {
input.attachEvent("onkeypress", handler);
}