password_confirm_validate

  1. drupal
    1. 5
    2. 6
    3. 7
    4. 8
Versions
5 password_confirm_validate($form)
6 password_confirm_validate($form, &$form_state)
8 – 7 password_confirm_validate($element, &$element_state)

Validate password_confirm element.

Related topics

Code

includes/form.inc, line 2780

<?php
function password_confirm_validate($element, &$element_state) {
  $pass1 = trim($element['pass1']['#value']);
  $pass2 = trim($element['pass2']['#value']);
  if (!empty($pass1) || !empty($pass2)) {
    if (strcmp($pass1, $pass2)) {
      form_error($element, t('The specified passwords do not match.'));
    }
  }
  elseif ($element['#required'] && !empty($element_state['input'])) {
    form_error($element, t('Password field is required.'));
  }

  // Password field must be converted from a two-element array into a single
  // string regardless of validation results.
  form_set_value($element['pass1'], NULL, $element_state);
  form_set_value($element['pass2'], NULL, $element_state);
  form_set_value($element, $pass1, $element_state);

  return $element;

}
?>