我正在尝试匹配两个密码字段但其显示密码不匹配
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();
}
答案 0 :(得分: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 强>
equals("")
!
符号
醇>
答案 1 :(得分:1)
您应该在
之前添加!
_repasswordText.getText().toString().equals(_passwordText.getText().toString())
答案 2 :(得分:1)
您可以使用_repasswordText.getText().toString().contentEquals(_passwordText.getText().toString())