You are here

function password_confirm_validate in Drupal 4

Same name and namespace in other branches
  1. 5 includes/form.inc \password_confirm_validate()
  2. 6 includes/form.inc \password_confirm_validate()
  3. 7 includes/form.inc \password_confirm_validate()

Validate password_confirm element.

Related topics

File

includes/form.inc, line 781

Code

function password_confirm_validate($form) {
  $pass1 = trim($form['pass1']['#value']);
  if (!empty($pass1)) {
    $pass2 = trim($form['pass2']['#value']);
    if ($pass1 != $pass2) {
      form_error($form, t('The specified passwords do not match.'));
    }
  }
  elseif ($form['#required'] && !empty($_POST['edit'])) {
    form_error($form, 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($form['pass1'], NULL);
  form_set_value($form['pass2'], NULL);
  form_set_value($form, $pass1);
  return $form;
}