Android : Minimum Length of password in edittext

后端 未结 1 374
迷失自我
迷失自我 2021-01-02 12:03

In android is there any simple way of setting minimum password length in edittext? In xml there is only an option of max length but not minimum.

Options like setting

相关标签:
1条回答
  • 2021-01-02 12:27

    You can do some validation on the edittext when the user clicks submit.

    public void onSubmitClicked(View v) 
    { 
        String pass = passwordEditText.getText().toString(); 
        if(TextUtils.isEmpty(pass) || pass.length() < [YOUR MIN LENGTH]) 
        { 
            passwordEditText.setError("You must have x characters in your password"); 
            return; 
        }
    
        //continue processing
    
    }
    
    0 讨论(0)
提交回复
热议问题