0

I am trying to match two field that is of password but its showing password do not match

 else if (_passwordText.getText().toString().equals("") || _passwordText.length() < 4 || _passwordText.length() > 10) {
        AlertDialog alertDialog = new AlertDialog.Builder(Register.this).create();
        alertDialog.setTitle("oops!");
        alertDialog.setMessage("Password  field is empty");
        alertDialog.show();
    }


   else if (_repasswordText.getText().toString().equals(_passwordText.getText().toString())) {
        AlertDialog alertDialog = new AlertDialog.Builder(Register.this).create();
        alertDialog.setTitle("oops!");
        alertDialog.setMessage("Passwords do not match");
        alertDialog.show();
        }
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Deepak
  • 187
  • 1
  • 1
  • 10

3 Answers3

4
else if (_passwordText.getText().toString().equals("")  {
        AlertDialog alertDialog = new AlertDialog.Builder(Register.this).create();
        alertDialog.setTitle("oops!");
        alertDialog.setMessage("Password  field is empty");
        alertDialog.show();
    }


   else if (!_repasswordText.getText().toString().equals(_passwordText.getText().toString())) {
        AlertDialog alertDialog = new AlertDialog.Builder(Register.this).create();
        alertDialog.setTitle("oops!");
        alertDialog.setMessage("Passwords do not match");
        alertDialog.show();
        }

FYI

  1. At first check equals("")
  2. Add ! sign before _repasswordText.getText().toString()
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

You should add ! before

_repasswordText.getText().toString().equals(_passwordText.getText().toString())
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Kingyal
  • 63
  • 8
0

You can use _repasswordText.getText().toString().contentEquals(_passwordText.getText().toString())