So I have this method which returns true if the validation is correct:
private boolean validation() {
String emailStr = etEmail.getText().toString();
if (emailStr.trim().isEmpty()) {
etEmail.setError(getResources().getString(R.string.eroareEmpty));
return false;
} else if (!emailStr.endsWith("stud.ase.ro") && emailStr.length() <= 15) {
etEmail.setError(getResources().getString(R.string.eroareEmail));
return false;
}
return true;
}
I want to verify that the text i type in EditText etEmail contains (only at the end of the string) "stud.ase.ro", the whole string not just a part of it. In simple words, i want to verify if the email ends with "stud.ase.ro" and nothing else.
Currently my method returns true, even if i type something unsual like "hellllllllllllooo@stud", which it shouldn't do.