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
  • 151,199
  • 17
  • 111
  • 216
Deepak
  • 175
  • 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
  • 73,189
  • 14
  • 161
  • 193
1

You should add ! before

_repasswordText.getText().toString().equals(_passwordText.getText().toString())
OneCricketeer
  • 151,199
  • 17
  • 111
  • 216
Kingyal
  • 53
  • 8
0

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