Description
I am developing one app in which I have registration page. Inside registration page, I am doing registration by getting user\'s full nam
Use trim()
method to remove the extra space
user_name.getText().toString().trim()
.
And Remove
if(str.length() > 0 && str.contains(" "))
{
user_name.setError("Space is not allowed");
user_name.setText("");
}
from your onTextChanged
To prevent user from entering space add this on your onTextChanged
if(str.equals(" "))
{
user_name.setError("Leading Space is not allowed");
user_name.setText("");
}