Android: Validatng password ,conform password and

2019-05-01 08:00发布

I have fields like password,conform password and gender in my registration page

password edit text

conform password edit text

gender (button01)/(button02)

for password and conform password i want to validate both fields ,I mean the entries(string value) of both fields should be same. If both are same then I want to pass only password value to the server not both values and In case of gender when I click button 01, I want to pass the input as male(string) to server and same in case of female also. How can I do this?

Help is always appreciated...!

1条回答
家丑人穷心不美
2楼-- · 2019-05-01 08:25
  • Check Password.

    Here i write one function for compare password and conform password . In that function you need pass both the password and it will return true if both password are same and return false if both are different.

     public boolean checkPassWordAndConfirmPassword(String password,String confirmPassword) 
     {
         boolean pstatus = false;
         if (confirmPassword != null && password != null) 
         {
           if (password.equals(confirmPassword)) 
           {
                pstatus = true;
           } 
         }
        return pstatus;
    }
    
  • Gender Button

    As you said that here you are taking two button for gender . One is for male and another is for female . so you when user click on male button you have to take one string variable and assing the "male" value to that string, if user click female then you have to set "female" to that variable and pass to the server.

查看更多
登录 后发表回答