1

I'm under pressure to close out some issues from a Qualys scan. One issue flagged was

150112 Sensitive form field has not disabled autocomplete

Suggestions include adding autocomplete="off" to the username and password fields.

What would be the best practice way to achieve this?

1
  • Any luck with the No Autocomplete module? Are you experiencing other issues? Commented Mar 24, 2016 at 10:26

3 Answers 3

3

It seems there is a module for this, No Autocomplete. As a sidenote (copied from the module's page:

However, browsers and password managers and the like may very well not respect the "autocomplete=off" attribute anyway. For example, Chrome seems no longer to respect it and Lastpass ignores it by default.

Well, good luck with Qualys!

3
  • This looks promising but should I be scared off by the maintenance status? Maintenance status: Seeking new maintainer. Development status: Maintenance fixes only
    – Rick
    Commented Mar 24, 2016 at 14:45
  • 1
    I wouldn't be scared off, it's a tiny module, code-wise. Basically implements a form alter call to add an extra attribute: $form['#attributes']['autocomplete'] = 'off'; Commented Mar 24, 2016 at 14:52
  • Did you get a chance to try this out? Commented Mar 29, 2016 at 6:14
1

Use hook_form_alter() in a Drupal module:

function hook_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login') {
    $form['pass']['#attributes']['autocomplete'] = 'off';
  }
}

Or use jQuery:

$('#edit-password').attr('autocomplete', 'off');
1

You can set the attribute autocomplete='off' in username and password field of login page hook_form_alter()

Tested on Drupal 8 using hook_form_alter()

function hook_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'user_login_form') {
    $form['name']['#attributes']['autocomplete'] = 'off';
    $form['pass']['#attributes']['autocomplete'] = 'off';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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