I created loggin panel and now i wanna check that username is only string. In other case i want to return "Bad username". So How can I check that textfield is only string ?
Asked
Active
Viewed 761 times
0
-
1String is a type in Java. Do you mean that username must contain only alphabets? Try Pattern matching, e.g. http://stackoverflow.com/questions/5238491/check-if-string-contains-only-letters – Mohit Kanwar Jun 30 '15 at 08:07
1 Answers
0
I am not sure what exactly you mean by if the username is a string?
If by string, you mean that your username consists of only characters i.e. A-Z (or a-z). You can check if each character in your username have the ascii value between 65 to 90 (for A-Z) or 97 to 122 (for a-z). If you want to allow any other characters such as underscore (ascii 242), add that also to the test.

Aakash
- 226
- 2
- 14