I have found how to validate that an input is a number using try/catch but how do I go about validating that a user input is alphabetical only and contains no numbers?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use a simple regular expression:
Note that this only works with letters
A-Zanda-z. If you need to properly support Unicode, a better method is to loop over the characters of the string and useCharacter.isLetter().