_user_password_dynamic_validation

Versions
6
_user_password_dynamic_validation()

Add javascript and string translations for dynamic password validation (strength and confirmation checking).

This is an internal function that makes it easier to manage the translation strings that need to be passed to the javascript code.

Code

modules/user/user.module, line 2191

<?php
function _user_password_dynamic_validation() {
  static $complete = FALSE;
  global $user;
  // Only need to do once per page.
  if (!$complete) {
    drupal_add_js(drupal_get_path('module', 'user') .'/user.js', 'module');

    drupal_add_js(array(
      'password' => array(
        'strengthTitle' => t('Password strength:'),
        'lowStrength' => t('Low'),
        'mediumStrength' => t('Medium'),
        'highStrength' => t('High'),
        'tooShort' => t('It is recommended to choose a password that contains at least six characters. It should include numbers, punctuation, and both upper and lowercase letters.'),
        'needsMoreVariation' => t('The password does not include enough variation to be secure. Try:'),
        'addLetters' => t('Adding both upper and lowercase letters.'),
        'addNumbers' => t('Adding numbers.'),
        'addPunctuation' => t('Adding punctuation.'),
        'sameAsUsername' => t('It is recommended to choose a password different from the username.'),
        'confirmSuccess' => t('Yes'),
        'confirmFailure' => t('No'),
        'confirmTitle' => t('Passwords match:'),
        'username' => (isset($user->name) ? $user->name : ''))),
      'setting');
    $complete = TRUE;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.