Can't access to password input on registration form I have a problem. I can't access through module to password field on registration page.

function customization_form_user_register_form_alter(&amp;$form, &amp;$form_state, $form_id) {
$form['account']['pass']['#id'] = 'userRegInput';
}


It wont change id of input. I don't know why...

Thank you!

EDIT: Btw. i have installed user_registrationpassword module, maybe is because of that...
You can access the password form field in the registration form, but the ID you are setting is not used.

When a password_confirm form field is being added to a form, Drupal is really adding two password form field with a process function (form_process_password_confirm()); that function doesn't use the ID set for the password_confirm field for the new fields.
There isn't a theme function for the password_confirm form field, which means that the following code (executed from theme_password(), and theme functions for other form fields) is not executed.

element_set_attributes($element, array('id', 'name', 'size', 'maxlength'));
_form_set_class($element, array('form-text'));


What you can do is to wrap the password_confirm form field with a &lt;div&gt; tag to which you assign your ID.

$form['account']['pass']['#prefix'] = '&lt;div id="userRegInput"&gt;';
$form['account']['pass']['#suffix'] = '&lt;/div&gt;';


If you are using the CSS ID to execute JavaScript code, or to style the field, keep in mind that the default output for the password_confirm field (for the form field you are interested) is the following one.

&lt;div class="form-item form-type-password-confirm form-item-pass"&gt;
  &lt;div class="form-item form-type-password form-item-pass-pass1 password-parent"&gt;
    &lt;div class="password-strength"&gt;
      &lt;div class="password-strength-text" aria-live="assertive"&gt;&lt;/div&gt;
      &lt;div class="password-strength-title"&gt;Password strength:&lt;/div&gt;
      &lt;div class="password-indicator"&gt;
        &lt;div class="indicator"&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;label for="edit-pass-pass1"&gt;Password &lt;span class="form-required" title="This field is required."&gt;*&lt;/span&gt;&lt;/label&gt;
    &lt;input class="password-field form-text required password-processed" type="password" id="edit-pass-pass1" name="pass[pass1]" size="25" maxlength="128"&gt;
  &lt;/div&gt;
  &lt;div class="form-item form-type-password form-item-pass-pass2 confirm-parent"&gt;
    &lt;div class="password-confirm"&gt;Passwords match: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
    &lt;label for="edit-pass-pass2"&gt;Confirm password &lt;span class="form-required" title="This field is required."&gt;*&lt;/span&gt;&lt;/label&gt;
    &lt;input class="password-confirm form-text required" type="password" id="edit-pass-pass2" name="pass[pass2]" size="25" maxlength="128"&gt;
  &lt;/div&gt;
  &lt;div class="password-suggestions description" style="display: none; "&gt;&lt;/div&gt;
  &lt;div class="description"&gt;Provide a password for the new account in both fields.&lt;/div&gt;
&lt;/div&gt;


The HTML output includes also the output from the JavaScript code that outputs the password strength.

As alternative, you can add a process function that is executed after the process functions normally used by Drupal.

$form['account']['pass']['#process'] = array('form_process_password_confirm', 'mymodule_process_password_confirm', 'user_form_process_password_confirm');


Use form_process_password_confirm() as guideline for the code you should write.

function form_process_password_confirm($element) {
  $element['pass1'] =  array(
    '#type' =&gt; 'password', 
    '#title' =&gt; t('Password'), 
    '#value' =&gt; empty($element['#value']) ? NULL : $element['#value']['pass1'], 
    '#required' =&gt; $element['#required'], 
    '#attributes' =&gt; array('class' =&gt; array('password-field')),
  );
  $element['pass2'] =  array(
    '#type' =&gt; 'password', 
    '#title' =&gt; t('Confirm password'), 
    '#value' =&gt; empty($element['#value']) ? NULL : $element['#value']['pass2'], 
    '#required' =&gt; $element['#required'], 
    '#attributes' =&gt; array('class' =&gt; array('password-confirm')),
  );
  $element['#element_validate'] = array('password_confirm_validate');
  $element['#tree'] = TRUE;

  if (isset($element['#size'])) {
    $element['pass1']['#size'] = $element['pass2']['#size'] = $element['#size'];
  }

  return $element;
}


user_form_process_password_confirm() just adds the JavaScript code to handle the password strength, and any messages about the used password (e.g. Make it at least 6 characters, Make it different from your username).

I tried using the following code in my test site, and the output for the password field didn't change.

function code_testing_form_user_register_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['account']['pass']['#attributes'] = array('id' =&gt; array('userRegInput'));
}


The ID is not being added to the form field.

&lt;div class="form-item form-type-password-confirm form-item-pass"&gt;
  &lt;div class="form-item form-type-password form-item-pass-pass1 password-parent"&gt;
    &lt;div class="password-strength"&gt;
      &lt;div class="password-strength-text" aria-live="assertive"&gt;&lt;/div&gt;
      &lt;div class="password-strength-title"&gt;Password strength:&lt;/div&gt;
      &lt;div class="password-indicator"&gt;
         &lt;div class="indicator"&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;label for="edit-pass-pass1"&gt;Password &lt;span class="form-required" title="This field is required."&gt;*&lt;/span&gt;&lt;/label&gt;
    &lt;input class="password-field form-text required password-processed" type="password" id="edit-pass-pass1" name="pass[pass1]" size="25" maxlength="128"&gt;
  &lt;/div&gt;
  &lt;div class="form-item form-type-password form-item-pass-pass2 confirm-parent"&gt;
    &lt;div class="password-confirm"&gt;Passwords match: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
    &lt;label for="edit-pass-pass2"&gt;Confirm password &lt;span class="form-required" title="This field is required."&gt;*&lt;/span&gt;&lt;/label&gt;
    &lt;input class="password-confirm form-text required" type="password" id="edit-pass-pass2" name="pass[pass2]" size="25" maxlength="128"&gt;
  &lt;/div&gt;
  &lt;div class="password-suggestions description" style="display: none; "&gt;&lt;/div&gt;
  &lt;div class="description"&gt;Provide a password for the new account in both fields.&lt;/div&gt;
&lt;/div&gt;