If you want a function to validate user input while typing and ignore non-digit keyboard entries, then no, there is no standard function to do that. You have to write your own. isalpha() will not tell you whether a character is a digit or not -- use isdigit() for that. isalpha() indicates that a character is alphabetic ('a'-'z' or 'A' - 'Z'), and those are 52 out of possible 255. So when isalpha() fails doesn't mean that the character is a numeric digit.