I am writing a program, part of it requires the input of a name. The name can only be alpha and spaces (eg. John Smith) it cannot be John Smith1 If an invalid character IS
You might want to look into regular expressions:
^[A-Za-z ]*$
is a regex that only matches strings if they consist entirely of ASCII letters and spaces.
To also allow letters of your current locale:
^[^\W\d_]*$
which is basically the set of alphanumeric characters including accented characters (in the current locale) minus digits and underscore.