5

I have a login form and I NEED to force autocomplete to off. i have tried

jquery: $('#login').attr("autocomplete", "off");

HTML: <input ... autocomplete="off">

Javascript: document.getElementById('myInputId').autocomplete = 'off';

When I click the login input box a drop down appears across all browsers FF, Chrome, IE..

N.B. this applies to users who have previously saved password information They need to forced to enter login details

Sunny Patel
  • 535
  • 2
  • 5
  • 13

7 Answers7

10

Or add with jQuery: $("input, select, textarea").attr("autocomplete", "off");

Robbie JW
  • 729
  • 1
  • 9
  • 22
Vitor Schweder
  • 154
  • 1
  • 5
2

The W3Schools states (tested):

<input type="email" name="email" autocomplete="off" />

Please note that this is defined in HTML5

For previous version see this SO

Community
  • 1
  • 1
Stefano Altieri
  • 4,550
  • 1
  • 24
  • 41
2

Worked for Chrome onFocus remove readonly - but onBlur you have to re-write it. So:

onFocus="this.removeAttribute('readonly');"
onBlur="this.setAttribute('readonly', true);"

This did the trick. For IE and Firefox I added in any case the autocomplete="off" with jQuery on "ready" function to all fields that might need it (marking them with a class (or cssclass):

$(document).ready(function () {
    $(".noautocomplete").attr("autocomplete", "off");
});
Sam
  • 940
  • 3
  • 13
  • 32
CallMeKat
  • 21
  • 2
0

Try this

  1. Add disabled attribute to the form fields( email, password, etc.)

    syntax: <input type="email" name="email" class="email" autocomplete="off" disabled />
    
  2. On Page Load enable the fields after few miliseconds.

    use the below JS CODE.

    function getRidOffAutocomplete(){
    
        var timer = window.setTimeout( function(){
            $('.email').prop('disabled',false);
            clearTimeout(timer);
           },
           800);
    }
    
    // Invoke the function, handle page load autocomplete by chrome.
    getRidOffAutocomplete();
    
0

Try this:

$(document).ready(function(){
    $( document ).on( 'focus', ':input', function(){
        $( this ).attr( 'autocomplete', 'off' );
    });
});

Or this:

$(document).ready(function(){ 
    $("input").attr("autocomplete", "off");
}); 

On the other hand, you might have a look at this Chrome Browser Ignoring AutoComplete=Off.

Murat Yıldız
  • 11,299
  • 6
  • 63
  • 63
0

Enclose "form-group" class in form tag and add onSubmit handler with event.preventDefault() method called inside the handler.

0

The attribute autocomplete="off" should work in all major browsers.

<input type="password" name="password" autocomplete="off" />

And if someone looking for the react-semantic-ui solution like me, this should do the trick:

<Form.Input autoComplete='new-password' type="password" />

Will render:

<div class="field">
  <div class="ui input">
  <input type="password" autocomplete="new-password" />
</div>

https://github.com/Semantic-Org/Semantic-UI-React/issues/3743

monkey-0001
  • 442
  • 6
  • 14