1.20.x 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()

File

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

Code

function user_form_process_password_confirm($element) {
  $confirm_settings = array(
    'confirmTitle' => t('Passwords match: '),
    'confirmSuccess' => t('yes'),
    'confirmFailure' => t('no'),
  );

  $element['#attached']['js'][] = backdrop_get_path('module', 'user') . '/js/user.js';
  $element['pass2']['#attributes']['data-password-confirm'] = backdrop_json_encode($confirm_settings, FALSE);

  return $element;
}