I have two EditTexts, one for entering password and other for confirm this password.Maximum length of these edittexts are 5.
confirmPwdEdiText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) { }
public void onTextChanged(CharSequence charSequence, int start, int before, int count)
{
String pwd = passwordEdiText.getText().toString();
String confirmaion = charSequence.toString();
if ((pwd == null || pwd.trim().length() <= 0) && confirmaion.trim().length() > 0) {
Toast.makeText(context,"Enter password",Toast.LENGTH_SHORT).show();
}
else if (pwd != null && pwd.trim().length() > 0 ) {
if(confirmaion.trim().length() == pwd.length()) {
if (pwd.equals(confirmaion)) {
password = pwd;
Toast.makeText(context,"Passwords match",Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(context,"Passwords do not match",Toast.LENGTH_SHORT).show();
}
}
}
}
});
When i am using this for confirm password the 'Passwords do not match' toast shows again when deleting the password.How can i confirm password in an efficient way without using button click or any other ?
Thanks in Advance
You can add one button and onClick Listener of button validate your password.