Could do some with help I am a big time beginner

  • Replies:1
Daniel Cowan
  • Forum posts: 2

Mar 16, 2016, 5:16:03 PM via Website

Hi, I am completely new to android development and even using Java to be honest. I am expected to create an application that contains a Sign Up Page, I have the page set up and I have the code below as validation for when the button is pressed however it doesn't seem to work. When I press the button it should run the validation and if it doesn't meet the requirements should show the Toast Message, however even when it does meet the requirements it stays on that page and shows the toast message instead of proceeding.

 public boolean validation() {
    if (strUser.isEmpty() || strUser.length() < 3 || strUser.length() > 10 || strUser.equalsIgnoreCase("") || strPasswd.isEmpty() || strPasswd.length() < 3 || strPasswd.length() > 10 || confirmPasswd.isEmpty() ||
            confirmPasswd.length() < 3 || confirmPasswd.length() > 10 || strPasswd != confirmPasswd) {
        Toast.makeText(getApplicationContext(), "Please fill fields correctly", Toast.LENGTH_LONG).show();
        return false;
    } else {
        if (strUser.length() > 3 || strUser.length() < 10 || strPasswd.length() > 3 || strPasswd.length() < 10 || confirmPasswd.length() > 3 || confirmPasswd.length() < 10
                || strPasswd.equals(confirmPasswd)) {
            Intent intent;
            intent = new Intent(SignupActivity.this, LoginActivity.class);
            startActivity(intent);
            return true;
        }

    }
    return true;
}


/* Login Button Handler */
class ButtonHandler implements View.OnClickListener {
    public void onClick(View v) {
        validation();
    }
} // Ends ButtonHandler

What it is supposed to do is when the button is pressed run the validation and if it doesn't meet the requirements show the toast message but if it does it is supposed to go back to the LogInActivity.

Sorry if this is in the wrong Place or completely irrelevant just my university lecturer assigned the class this and we are all getting lost in different points. If you need any other information please don't hesitate to ask.

Reply
Vladimir S.
  • Forum posts: 266

Mar 16, 2016, 6:52:20 PM via Website

Hi, you need to delete this code:

       if (strUser.length() > 3 || strUser.length() < 10 || strPasswd.length() > 3 || strPasswd.length() < 10 || confirmPasswd.length() > 3 || confirmPasswd.length() < 10
            || strPasswd.equals(confirmPasswd)) {

Daniel Cowan

Reply