Home > Back-end >  If case only checks one of the things
If case only checks one of the things

Time:08-12

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();
  • Related