This code accepts either one, what i need is for both of them to be checked and return. Where am i making the mistake?
if(!email.endsWith(".com") && !email.contains("@")) {
Toast.makeText(view.context,
"Please enter a correct email", Toast.LENGTH_SHORT).show();
CodePudding user response:
Just change the AND to a OR.
if(!email.endsWith(".com") || !email.contains("@")) {
Toast.makeText(view.context,
"Please enter a correct email", Toast.LENGTH_SHORT).show();