I'm working on a Registration UI and it checks if the user already exists in the database, the program works fine and all, but i have received bug reports that if you add whitespace at the start or end of the name you entered, it will assume its a new name and won't be blocked by detecting that the name already exists.
String name = txfUName.getText();
If(this.checkIfNameExists(name) == true);
{
...
}
else
{
...
}
How would I check if the first and last character is a whitespace (in a loop) and replace that whitespace with an empty string "" until there are no whitespaces in front or at the back of the name, assume the name can contain whitespaces in between words.