I actually wrote something just like this recently:
var oldnumber=0;
var $ctrl=$('input[name=passport_number]');
$ctrl.focusout(function () {
if (isFinite($ctrl.attr('value'))) {
oldnumber=$ctrl.val();
} else {
$ctrl.attr('value',oldnumber);
}
});
Basically, if you type in a number, it remembers that number. If you write anything but a number, the field is set back to its previous value.
My solution is decently short and pretty darn clean if you ask me. It checks if it is a number, if not, it denies your entry.
Hope that helps :)