user_form_process_password_confirm

7 user.module user_form_process_password_confirm($element)
8 user.module user_form_process_password_confirm($element)

Form element process handler for client-side password validation.

This #process handler is automatically invoked for 'password_confirm' form elements to add the JavaScript and string translations for dynamic password validation.

See also

system_element_info()

1 string reference to 'user_form_process_password_confirm'

File

modules/user/user.module, line 3512
Enables the user registration and login system.

Code

function user_form_process_password_confirm($element) {
  global $user;

  $js_settings = array(
    'password' => array(
      'strengthTitle' => t('Password strength:'), 
      'hasWeaknesses' => t('To make your password stronger:'), 
      'tooShort' => t('Make it at least 6 characters'), 
      'addLowerCase' => t('Add lowercase letters'), 
      'addUpperCase' => t('Add uppercase letters'), 
      'addNumbers' => t('Add numbers'), 
      'addPunctuation' => t('Add punctuation'), 
      'sameAsUsername' => t('Make it different from your username'), 
      'confirmSuccess' => t('yes'), 
      'confirmFailure' => t('no'), 
      'weak' => t('Weak'), 
      'fair' => t('Fair'), 
      'good' => t('Good'), 
      'strong' => t('Strong'), 
      'confirmTitle' => t('Passwords match:'), 
      'username' => (isset($user->name) ? $user->name : ''),
    ),
  );

  $element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
  // Ensure settings are only added once per page.
  static $already_added = FALSE;
  if (!$already_added) {
    $already_added = TRUE;
    $element['#attached']['js'][] = array(
      'data' => $js_settings,
      'type' => 'setting',
    );
  }

  return $element;
}
Login or register to post comments