title: Signup validation form error Android
body: <p>I'm writing some code to sign up for a parse account. I'm using various validation regexs' for my Username, Email and Password. But everytime I run this, it fails bringing up errors I've put. </p>
  
  <p>Here's the code,</p>
  
  <pre><code>   private boolean isFormInputValid(String username, String password, String c_password, String email, String name) {
      mUsernameEtxt.setError(null);
      mPasswordEtxt.setError(null);
      mCPasswordEtxt.setError(null);
      mEmailEtxt.setError(null);
      mNameEtxt.setError(null);
  
      // validate the username
      if (username == null || username.isEmpty()) {
          mUsernameEtxt.setError(getString(R.string.error_username));
          mUsernameEtxt.requestFocus();
          return false;
      }
  
  
      // validate the password
      if (password == null || password.isEmpty()) {
          mPasswordEtxt.setError(getString(R.string.error_password));
          mPasswordEtxt.requestFocus();
          return false;
      }
  
  
      // validate the confirm password
      if ((!c_password.equals(password))) {
          mCPasswordEtxt.setError(getString(R.string.error_c_password));
          mCPasswordEtxt.requestFocus();
          return false;
      }
  
  
      // validate the email
      if (email == null || email.isEmpty()) {
          mEmailEtxt.setError(getString(R.string.error_email));
          mEmailEtxt.requestFocus();
          return false;
      }
  
      // validate the name
      if (name == null || name.isEmpty()) {
          mNameEtxt.setError(getString(R.string.error_name));
          mNameEtxt.requestFocus();
          return false;
      }
      return true;
  }
  
  public boolean isValidUsername(final String username) {
  
      Pattern pattern;
      Matcher matcher;
  
      final String USERNAME_PATTERN = "^[a-zA-Z0-9._-]{4,}$";
  
      pattern = Pattern.compile(USERNAME_PATTERN);
      matcher = pattern.matcher(username);
  
      return matcher.matches();
  
  }
  
  public boolean isValidPassword(final String password) {
  
      Pattern pattern;
      Matcher matcher;
  
      final String PASSWORD_PATTERN = "(?=.*[0-9])(?=.*[a-z])(?=\\S+$).{8,}$";
  
      pattern = Pattern.compile(PASSWORD_PATTERN);
      matcher = pattern.matcher(password);
  
      return matcher.matches();
  
  }
  
  public boolean isValidEmail(final String email) {
  
      Pattern pattern;
      Matcher matcher;
  
      final String EMAIL_PATTERN = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\\\.[A-Z]{2,6}$";
  
      pattern = Pattern.compile(EMAIL_PATTERN);
      matcher = pattern.matcher(email);
  
      return matcher.matches();
  
  }
  
  // OnClickListener Implementations
  private class SignUpOnClickListener implements View.OnClickListener {
  
      @Override
      public void onClick(View v) {
          // Get the username and password from the view
          String username = mUsernameEtxt.getText().toString().toLowerCase().trim();
          String password = mPasswordEtxt.getText().toString().trim();
          String c_password = mCPasswordEtxt.getText().toString();
          String email = mEmailEtxt.getText().toString().trim();
          String name = mNameEtxt.getText().toString().trim();
          if (isFormInputValid(username, password, c_password, email, name)) {
              if (isValidUsername(mUsernameEtxt.getText().toString().trim())) {
                  if (isValidPassword(mPasswordEtxt.getText().toString().trim())) {
                      if (isValidEmail(mEmailEtxt.getText().toString().trim())) {
                          ParseUser user = new ParseUser();
                          user.setUsername(username);
                          user.setPassword(password);
                          user.setEmail(email);
                          user.put("name", name);
                          user.signUpInBackground(new SignUpCallback() {
                              public void done(ParseException e) {
                                  if (e == null) {
                                      // Successful sign up, take user to the MainActivity
                                      Intent intent = new Intent(getBaseContext(), MainActivity.class)
                                              .addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
                                                      Intent.FLAG_ACTIVITY_CLEAR_TASK);
                                      startActivity(intent);
                                      finish();
                                  } else {
                                      // Sign up didn't succeed, most likely the username/email is taken
                                      TextView error = (TextView) findViewById(R.id.error);
                                      error.setVisibility(View.VISIBLE);
                                      error.setText(getString(R.string.error_username_email_taken));
                                  }
                              }
                          });
                      }else{
                          mEmailEtxt.setError(getString(R.string.error_email_notvalid));
                          TextView error = (TextView) findViewById(R.id.error);
                          error.setVisibility(View.VISIBLE);
                          error.setText(getString(R.string.error_email_notvalid_detail));
  
                          Log.d("error", "email invalid");
                      }
                  }else {
                      mPasswordEtxt.setError(getString(R.string.error_password_weak));
                      TextView error = (TextView) findViewById(R.id.error);
                      error.setVisibility(View.VISIBLE);
                      error.setText(getString(R.string.error_password_weak_detail));
  
                      Log.d("error", "password invalid");
                  }
              } else {
                  mUsernameEtxt.setError(getString(R.string.error_username_notvalid));
                  TextView error = (TextView) findViewById(R.id.error);
                  error.setVisibility(View.VISIBLE);
                  error.setText(getString(R.string.error_username_notvalid_detail));
  
                  Log.d("error", "username invalid");
              }
  
          }
      }
  }
  </code></pre>