I'm looking for the easiest possible way to modify or alter the password policy constraints error text. The following is the default the users see.

The password does not include enough variation to be secure. Password must contain characters of at least 3 different types (lowercase, uppercase, digit or punctuation). Password must contain at least one digit.
Password must be at least 8 characters in length.
Password must contain at least one lowercase character.
Password must contain at least one punctuation (not whitespace or an alphanumeric) character.
Password must contain at least one uppercase character.

I would like to modify it to the following text.

Password must: • Be at least 8 characters
• Have at least one lowercase character
• Have at least one uppercase character
• Have at least one digit
• Have at least one punctuation character

Would this be possible using hook_form_alter() or other methods?

1 Answer 1


Short answer:

Of course there is a module for that.

Actually, more than one:

https://www.cmsdrupal.com/blog/how-implement-custom-password-policy-drupal https://dev.acquia.com/blog/password-policies-and-drupal/03/04/2017/17856

Longer answer:

Since you don't just want to change the policy (you want to change the form markup too) you might also need to use hook_form_user_login_block_alter(&$form, &$form_state, $form_id).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.