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 ems and width fits for restricting the length but what about when to set minimum length???
I found this in the documentation:
DevicePolicyManager mDPM;
ComponentName mDeviceAdminSample;
int pwLength;
...
mDPM.setPasswordMinimumLength(mDeviceAdminSample, pwLength);
But is there any simpler method other than this?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With