Reputation: 332
How do I make it that unless the first if else is fulfilled because even when the passwords do not match the user still get registered. (I'm really bad at programming sorry...)
if(cfmpassword.equals(password)) {
} else {
Toast.makeText(getApplicationContext(),
"Passwords do not match!",Toast.LENGTH_LONG)
.show();
}
Then this will run.
if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) {
registerUser(name, email, password);
} else {
Toast.makeText(getApplicationContext(),
"Please enter your details!", Toast.LENGTH_LONG)
.show();
}
}
});
Upvotes: 0
Views: 112
Reputation: 155
Hope it's helpful.
private boolean validateData() {
if (!etNewPassword.getText().toString()
.equals(etVerifyPassword.getText().toString())) {
Toast.makeText(context, "Verify password is failed",
Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
Upvotes: 0
Reputation: 4235
Your problem is that the second block of code will run regardless of whether or not the password matches. Place the second block within the first if statement.
Also, I'm not sure how you're handling your user accounts, but I would strongly recommend a service like Parse. It is free for smaller apps, and very well priced for apps as they grow (to a certain point). It will handle all your user accounts and password creation and backend stuff that will otherwise be a large headache.
There are also other BaaS (backend as service) options out there besides Parse.
Upvotes: 1