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
First, try to understand what he is trying to do
He is trying to prevent user typing leading spaces and not after entering text.
He doesn't want to trim username
Update your code from
if(str.length() > 0 && str.contains(" "))
{
user_name.setError("Space is not allowed");
user_name.setText("");
}
to
if(str.equals(" "))
{
user_name.setError("Leading Space is not allowed");
user_name.setText("");
}
It will prevent user typing any space before name