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

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

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

You can use user_validate_current_pass()

  • would this work with my custom system where passwords are not stored in drupal? – pal4life Dec 4 '14 at 19:54
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, privacy policy and cookie policy

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