1

I am using the Drupal Form API for a customized Login System. It has the password field which needs to be validated. We have a custom criteria of Uppercase, Lowercase, numeric and special characters to validate the password.

The one way I see is to write the RegEx inside the Validate function. Is there an alternate way in Drupal to do this via an existing function or module?

(I am aware that the Webform Validation Module can do this for the webforms.)

Thanks.

2

2 Answers 2

2

Please check Password Policy module. It will satisfy all your above requirements (Uppercase, Lowercase, numeric and special characters).

1
  • I confirm this suggestion, Password Policy allow you to improve your own password validators, including error messages and enforcing-security :)
    – Tarto
    May 17, 2016 at 10:57
0

If you want to use password field in custom form do not have to use any custom modules use drupal password settings.

Just add type as 'password_confirm' in your form.

This automatically add confirm password field and match all the password standards of drupal.

 $form['pass'] = array(
    '#type' => 'password_confirm',
    '#size' => 25,
    '#description' => t('Enter the new password in both fields.'),
 );

Your Answer

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

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