Check whether user input is numeric

Found on stackoverflow
http://stackoverflow.com/a/1235990/1253966