jQuery's implementation (in pure JavaScript): function ... This works, but it is an overkill for digit-only check (it works with multi-digit numbers).
stackoverflow.com