It works as I expected. It 's just probably not what you expected.
Input: 100 -> no error msg
Input: kkk -> error msg
Input: 100k -> no error msg, because it only reads the '100' and 'k' is left in the stream for another input method to fetch. I suppose you want this kind of input to give error message, so what you need to is, not sure, but read the input as a string and make sure all characters in the string are digits.

04-01-2004

bj31t

i am wanting it to only take in numbers as input and give an error message for anything else.