1

How can tell the browser not to save drupal usrrname and password? I am newbie. So having difficulty understand many functions. Any easy way to configure drupal for this? Thanks

closed as off-topic by Bala, Free Radical, Mołot, Clive Dec 17 '13 at 9:24

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on programming, PHP, SQL, etc. that do not relate directly to Drupal are off-topic here, but can be asked on Stack Overflow." – Free Radical, Mołot, Clive
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is not a drupal question.. This is a default behavior of browsers. – xurshid29 Dec 17 '13 at 6:30
  • Hello. This is off-topic here, as general HTML / JS question. Unless you know how to do that in pure HTML+JS. If you do, tell us how and we can tell you how to implement it in Drupal. – Mołot Dec 17 '13 at 7:36
  • did you try this module? drupal.org/project/no_autocomplete – shekoufeh Mar 4 '17 at 5:53
3

Auto-completion of common fields (text, password, select, textarea, date-related, time-related, numeric, email, and uri controls) is a browser feature but you can tell browsers to turn off auto-completion on form fields by using the autocomplete attribute.

You can use hook_form_alter or hook_form_FORM_ID_alter to add this attribute to your fields.

Example:

/**
 * Implements hook_form_alter().
 */
function example_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'YOUR_FORM_ID') {
    $form['YOUR_FIELD']['#attributes']['autocomplete'] = 'off';
  }
}

Example altering the log-in forms:

function example_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_login_block': // Log-in block form.
    case 'user_login': // Log-in form.
      // Username
      $form['name']['#attributes']['autocomplete'] = 'off';

      // Password
      $form['pass']['#attributes']['autocomplete'] = 'off';
      break;
  }
}

You can check out these posts for more info on module development - Module Developer's Guide and Creating Drupal 7.x modules. You can also download the excellent Examples module for reference.

  • Many Thanks. Say for example i want to disable the login username and password fields. Where/ in which file do i put the above code? Sorry, dont have any idea about drupal structure. – Tapash Dec 17 '13 at 6:43
  • I have updated my answer to show an example that alters the log-in form. – angheloko Dec 17 '13 at 10:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.