Stop LastPass filling out a form
Asked Answered
M

21

196

Is there a way to prevent the LastPass browser extension from filling out a HTML-based form with an input field with the name "username"?

This is an hidden field, so I don't want any software to use this field for their purposes:

<input type="text" name="username" id="checkusername" maxlength="9" value="1999" class="longinput" style="display:none">

The solution should not be like "rename the input field".

Mcmurry answered 6/1, 2014 at 16:49 Comment(2)
If the field is hidden, it's better to set type="hidden" instead of hide it with CSSOdyssey
super simple $(':input').attr('data-lpignore', true); Thats all. This will diable lastpass form filling on all the forms.Malkamalkah
H
295

Adding

data-lpignore="true"

to an input field disabled the grey LastPass [...] box for me.

Sourced from LastPass.com

Hautrhin answered 8/7, 2017 at 10:2 Comment(12)
This should be the valid answer. LP seems to respect this attribute and does not require any crazy "search" names or ids or roles.Dharana
this only removes grey icon, but does not stop LastPass to ignore input autofillShellishellie
this should NOT be the accepted answer since this does NOT "Stop LastPass filling out a form"Illimitable
Per the link provided in the answer (lastpass.com/support.php?cmd=showfaq&id=10512) , LP only prevents the icon from being displayed on that fieldOutlive
According to the LastPass documentation this should work. support.logmeininc.com/lastpass/help/…. Quote: "To prevent LastPass from autofilling certain fields on specific sites or applications that you have control over, you can edit your item(s) to add the 'data-lpignore'=true attribute within those form fields which you do not want to autofill."Bedevil
Tried this in 2020 and it DOES stop LastPass from auto filling the input field that has this data attribute.Abnormity
Reiterating other recent comments... LastPass seems to have improved/fixed this since the comments made in 2017 & 2018 saying that it doesn't stop autofill. It definitely does stop autofill now (Dec 2020).Mawkish
I also found that lastpass in 2021 was overwriting my autocomplete values, including "new-password" without setting data-lpignore="true". I also have set the value in the extension to respect autocomplete="off"Tabbitha
It is also worth noting that you'll have to set data-lpignore="true" on each input element that you want to be ignored. Simply adding it to the wrapping <form> in the expectation it will ignore all inner inputs won't work. Thanks Obama.Goar
With the v4.104.0 release in November '22 (lastpass.com/upgrade.php) this does not seem to work any longer.Cardigan
Looks to me that if you disable the "Use improved Save and Fill" Advanced Option in the LastPass vault itthe data-lpignore=true attribute still works. Will check if there is already a bug report on this.Archery
This never works without also having applied the wisdom in @takeshin's answer.Dela
G
82

Three conditions have to be met:

  1. The form (not the element) needs to have autocomplete="off" attribute
  2. Input fields need to have the attribute data-lpignore="true"
  3. Lastpass user needs to have this option enabled:
    • (old) Settings > Advanced > Allow pages to disable autofill
    • (new) Account Options > Extension Preferences > Advanced > Respect AutoComplete=off: allow websites to disable Autofill

So this depends on both user and the developer.

Official documentation from LastPass confirms this method is the way to go.

Grandee answered 29/1, 2015 at 14:19 Comment(4)
Is this still accurate? I cannot find the setting to allow pages to disable autofill in any of the settings menus in LastPass.Electrocautery
In newer versions the setting can be found at Account Options > Extension Preferences > Advanced > "Respect AutoComplete=off: allow websites to disable Autofill"Preach
I cant even find Account Options in my Chrome extension. All I have is Account Settings and Advanced Options. In neither spot I find any an Respect AutoComplete=off option....Archery
I have found simply putting autocomplete="off" on the form elements you wish to disable works fine. You'll still need to do step 3 above, however you don't have to place autocomplete="off" on the form, or include data-lpignore="true".Ingratitude
F
44

What worked for me is having word "-search-" in the id of the form, something like <form id="affiliate-search-form"> - and lastpass doesn't add its elements onto the form inputs. It works with something simpler like <form id="search"> but doesn't work with <form id="se1rch">

Forgotten answered 18/6, 2015 at 17:9 Comment(9)
Also it is suppressed if: - if field name or class attribute contains words "search" or "srch" - if form id or name atttribute contains "search" - form role attribute is "search"Alphabetize
Unfortunately, this does not work for password fields. Effectively, the form is still auto-filled. In my case, adding search as classes to both username and password disabled the asterisk button on the username field, but the password field remains as is.Muckworm
Yes, I can confirm that password fields are still filled when using this approach. :-(Whitethroat
This no longer applies to current Lastpass versions. So this answer should be removed.Degenerate
adding "srch" removes the icons/autofill from text input; works as of today on Chrome and EdgeNydianye
Add -search- to the id of a single input field works for me on Chrome 51, LastPass 4.1.17. Adding it to the form does not help.Pluralism
I have a form called setup_search_form and this did, in fact, hide LastPass for me (for usernames, not for passwords).Thermostatics
See @CreeTar's answer below & use type=searchRobinrobina
id="search" on the form hides the icons on text input boxes for me in Firefox and Chrome with the latest version of LastPass today (2020-12-18). Good easy solution for a form that doesn't need an ID for anything else anyway, thank you!Curtal
R
19

I know I'm late to the party here, but I found this when I was trying to stop lastpass from ruining my forms. @takeshin is correct in that autocomplete is not enough. I ended up doing the hack below just to hide the symbol. Not pretty, but I got rid of the icon.

If any lastpass developers are reading this, please give us an attribute to use, so we don't have to resort to stuff like this.

form[autocomplete="off"] input[type="text"] {
    background-position: 150% 50% !important;
}
Roveover answered 6/4, 2015 at 14:26 Comment(1)
This is the only solution that worked for me (even with playing with lastpass settings, which I don't actually expect my user to do anyway), though it does conflict with me setting my own background-image on input fields (I like to put "clear buttons" on input fields) - in which case what also worked for me was just setting background-image and background-position with !important to override the lastpass builtin style.Steersman
K
17

I think lastpass honors the autocomplete="off" attribute for inputs, but I'm not 100% sure.

EDIT As others have pointed out. this only works if the user has last pass configured to honor this.

Kinser answered 6/1, 2014 at 17:18 Comment(5)
Yes it does, but not by default: helpdesk.lastpass.com/extension-preferences/advancedMcmurry
I can confirm lastpass does not honour autocomplete="off" at the form level. That just wasted me an hour of development time on an "edit user" form which appeared to display the wrong email address. The lastpass preferences have a "do not overwrite fields that are already filled" option, which helps a lot.Hamer
As Marco stated, you need to activate this behavior. Preferences->Advanced->Respect AutoComplete=off: allow websites to disable AutoFillLuhey
how do you bypass this in lastpass?Rennet
I have not found this to be the case. LastPass in 2021 does not respect autocomplete="new-password" even with respect "autocomplete off" toggled on. you need lpignoreTabbitha
K
17

For me worked either type=search which is kinda equal to text or using role=note.

You can check the LastPass-JavaScript but it's huge, may be you can find some workaround there, from what I saw they only check 4 input types, so input type=search would be one workaround:

!c.form && ("text" == c.type || "password" == c.type || "url" == c.type || "email" == c.type) && lpIsVisible(c))

Also those are the role-keywords they seem to ignore:

var c = b.getAttribute("role");
switch (c) {
case "navigation":
case "banner":
case "contentinfo":
case "note":
case "search":
case "seealso":
case "columnheader":
case "presentation":
case "toolbar":
case "directory":`

I checked LastPass' onloadwff.js, prepare for 26.960 lines of code :)

Kerns answered 22/12, 2016 at 10:9 Comment(6)
I tried all the answers above and type=search is only thing that works for me.Robinrobina
+1, it seems using type=search is the only way to prevent the autofill regardless of the state of the LastPass "Respect autocomplete=off" setting.Adamite
Tried adding role="note" or type="search". None worked on latest Chrome and latest lastpass.Packing
it seems the lpignore is working again, fiddle me this https://jsfiddle.net/78z0L1sa/3/Kerns
OMG, this is annoying, LastPass was converting my type=text password field to type=password and on this particular screen password was required to be seen, then LastPass added the site password and not the correct password without the user knowing when they saved it was changing the credentials and breaking their connections to other systems. The lpignore, only removed the icon, the other solutions required user interaction, which isn't ideal. Finally, changing the type to search worked; although I hate having to do this because of someone else's software. Anyways, up-vote on this one.Shove
fyi if type=search gives you the annoying webkit styling, see https://mcmap.net/q/130006/-how-do-i-remove-all-default-webkit-search-field-styling for how to remove them.Atomism
A
11

Add "search" to input id

<input type="text" name="user" id="user-search"/>
Amitosis answered 20/10, 2015 at 15:56 Comment(1)
Works fine for me. Tested on latest Chrome. Its a bit of a hack, but not as potentially breaking as the others so I'll go for it.Corrigan
V
11

Bit late to the party but I have just achieved this with modifying the form with:

<form autocomplete="off" name="lastpass-disable-search">

I guess this fools lastpass into thinking that it's a search form. This does not work for password fields however! Lastpass ignores the name field in this case.

The only way I've managed to do this is to add the following directly at the top of the form:

<form autocomplete="off">
    <div id="lp" ><input type="text" /><input type="password" /></div><script type="text/javascript">setTimeout(function(){document.getElementById('lp').style.display = 'none'},75);</script>
</form>

It causes a nasty flicker but does remove the autofill nonsense - though it does still show the "generate password" widget. LastPass waits until domready and then checks to see if there are any visible password fields, so it's not possible to hide or shrink the mock fields above.

Vadavaden answered 12/1, 2016 at 16:58 Comment(0)
V
7

This ES6 style code was helpful for me as it added data-lpignore to all my input controls:

const elements = document.getElementsByTagName("INPUT");
for (let element of elements) {
    element.setAttribute("data-lpignore", "true");
}

To access a specific INPUT control, one could write something like this:

document.getElementById('userInput').setAttribute("data-lpignore", "true");

Or, you can do it by class name:

const elements = document.getElementsByClassName('no-last-pass');
for (let element of elements) {
    element.setAttribute("data-lpignore", "true");
}
Viator answered 5/5, 2018 at 18:12 Comment(0)
C
5

For this latest October 2019 buggy release of Lastpass, this simple fix seems to be best.

Add

type="search"

to your input.

The lastpass routine checks the type attribute to determine what to do with its autofill, and it does nothing on this html5 type of "search." This fix is mildly hacky, but it's a one line change that can be easily removed when they fix their buggy script.

Note: After doing this, your input might appear to be styled differently by some browsers if they pick up on the type attribute. If you observe this, you can prevent it from happening by setting the browser-specific CSS properties -webkit-appearance and -moz-appearance to 'none' on your input.

Calva answered 8/10, 2019 at 16:52 Comment(6)
There has been an element called data-lpignore which you can set on true now. This will disable lastpass from autofillingAmble
That's been around for years and is in answers all over this page. Didn't work for me. By all means, give it a go if it works and passes testing for you.Calva
Oh, i never seen anyone complain about this. I tested it and it worked for me. I'm confused why it doesn't work for you.Amble
It's literally the accepted answer. I don't know why you would think others haven't tried it. Check it out. But for many, many fields it doesn't stop LastPass from filling out the input.Calva
I never said that people didn't try it. I just said that i never seen any complaints about itAmble
Did you actually read the comments under the accepted answer?Calva
K
3

Try this one:

[data-lastpass-icon-root], [data-lastpass-root] {
    display: none !important;
}
Killiecrankie answered 24/11, 2022 at 0:48 Comment(3)
See "How to Answer" and Explaining entirely code-based answers". While this might be technically correct, it doesn't explain why it solves the problem or should be the selected answer. We should educate along with helping solve the problem.Parolee
Please don't post code-only answers. The main audience, future readers, will be grateful to see explained why this answers the question instead of having to infer it from the code. Also, since this is an old question, please explain how it complements all other answers.Arise
@Tin Man - Um, this is the perfect example of why a code only answer is acceptable... No explanation is needed.Yod
P
2

Here's what worked for me to prevent lastpass from filling a razor @Html.EditorFor box in Chrome:

Click the active LastPass icon in your toolbar, then go to Account Options > Extension Preferences.

On this screen check "Don't overwrite fields that are already filled" (at the bottom)

Next, click "advanced" on the left.

On this screen check "Respect AutoComplete=off: allow websites to disable Autofill".

I did not need to do anything special in my ASP cshtml form but I did have a default value in the form for the @Html.EditorFor box.

I hope this helps and works for someone. I could not find any Razor-specific help on this problem on the web so I thought I'd add this since I figured it out with the help of above link and contributions.

Paunchy answered 30/5, 2020 at 0:24 Comment(0)
H
2

Update 2023

While the autocomplete="no-lastpass" attribute has been suggested as a workaround in some cases, it is not guaranteed to work with all versions of LastPass or other autofill tools. Not in my case at least!

To disable LastPass autofill for certain fields, you can try using the readonly attribute and a bit of JavaScript to prevent the field from being editable.

<input type="text" readonly onfocus="this.removeAttribute('readonly');" onblur="this.setAttribute('readonly', true);" />

The readonly attribute is initially set on the input field, when the field receives focus, the readonly attribute is removed, allowing the user to enter data. Once the field loses focus, the readonly attribute is set again, disabling further editing.

This approach stopped LastPass from triggering autofill on specific fields.

Haberman answered 10/5, 2023 at 15:51 Comment(2)
Going to do some more testing but I think this is working for me. Also did Danail's addition above. I'll try anything! Oh, Lastpass...Sidewalk
@Sidewalk I find the js way more readable and elegant in many ways :)) I don't even understand what those css are needed for.Haberman
C
1

None of the options here (autocomplete, data-lpignore etc.) prevented LastPass from auto-filling my form fields unfortunately. I took a more sledge-hammer approach to the problem and asynchronously set the input name attributes via JavaScript instead. The following jQuery-dependent function (invoked from the form's onsubmit event handler) did the trick:

function setInputNames() {
    $('#myForm input').each(function(idx, el) {
        el = $(el);
        if (el.attr('tmp-name')) {
            el.attr('name', el.attr('tmp-name'));
        }
    });
}

$('#myForm').submit(setInputNames);

In the form, I simply used tmp-name attributes in place of the equivalent name attributes. Example:

<form id="myForm" method="post" action="/someUrl">
    <input name="username" type="text">
    <input tmp-name="password" type="password">
</form>

Update 2019-03-20

I still ran into difficulties with the above on account of AngularJS depending upon form fields having name attributes in order for ngMessages to correctly present field validation error messages.

Ultimately, the only solution I could find to prevent LastPass filling password fields on my Password Change form was to:

  1. Avoid using input[type=password]entirely, AND
  2. to not have 'password' in the field name

Since I need to be able to submit the form normally in my case, I still employed my original solution to update the field names 'just in time'. To avoid using password input fields, I found this solution worked very nicely.

Cress answered 17/1, 2018 at 22:4 Comment(0)
L
1

For someone who stumbles upon this - autocomplete="new-password" on password field prevents LastPass from filling the password, which in combination with data-lpignore="true" disables it at all

Lymphangitis answered 21/1, 2021 at 16:23 Comment(0)
P
1

None of these work as of 10/11/2022.

What I did was add the following to a fake password field

<input id="disable_autofill1" name="disable_autofill1" 
  style="height:0; width:0; background:transparent;
         border:none;padding:0.3px;margin:0;display:block;" 
type="password">

This seems to be enough to minimize the size this element takes on screen (pretty much 0 for me) while still not triggering last pass's vicious algorithm. Put it before the real password field.

I'm sure a variant of this could be used to fool last pass for other fields where we don't need autofill or to suggest a new password.

Prepuce answered 12/10, 2022 at 1:41 Comment(0)
B
0

Tried the -search rename but for some reason that did not work. What worked for me is the following:

  1. mark form to autocomplete - autocomplete="off"
  2. change the form field input type to text
  3. add a new class to your css to mask the input, simulates a password field
  4. css bit: input.masker { -webkit-text-security: disc; }

Tried and tested in latest versions of FF and Chrome.

Begone answered 15/3, 2017 at 15:41 Comment(0)
L
0

type="hidden" autocomplete="off"

Adding this to my input worked for me. (the input also had visibility: hidden css).

Livonia answered 2/2, 2021 at 20:51 Comment(0)
C
0

I had the same issue and wanted to prevent Lastpass from filling in data in disabled email input field. I had the issue in my next js application and I used the useEffect hook to attach an event listener to the email input field, specifically listening for the input event. Initially, I tried to prevent the default behaviour using event.preventDefault(), but, unfortunately, this method didn't work. As a workaround, I resolved the issue by reassigning the initial value whenever the event listener was triggered.

useEffect(() => {
    const emailField = document.getElementById("emailInput");
    emailField.addEventListener("input", (event) => {
      event.preventDefault(); 
      emailField.value = user.email;
    });
  }, []);
Canary answered 7/9, 2023 at 13:23 Comment(0)
T
0

The LastPass icon is a late arrival to the DOM. I came up with this to deal with it using jQuery/JavaScript:

$(document).ready(function(){
  setTimeout(function(){
  $('div[data-lastpass-icon-root]').css({'display': 'none'});
  }, 140);
});
Transfer answered 18/9, 2023 at 16:58 Comment(1)
You may have to start out with a higher number than 140 to see it happen (eg 300). Also, use Chrome inspector to see if div[data-lastpass-icon-root] is in the DOM... maybe LastPass changes the name every so often.Transfer
M
-1

Update NOV 2021

I have noticed that all LastPass widgets are wrapped in div of class css-1obar3y.

div.css-1obar3y {
  display: none!important;
}

But yeah, it's probably a bad way to go this way.

Moncear answered 9/11, 2021 at 19:57 Comment(2)
Friendly heads up: I wouldn't expect this to be a reliable solution. The class name appears to be generated and likely to change at any future point.Withdrawal
...and also to be different for different installed version. 1/10, would not use.Misread

© 2022 - 2024 — McMap. All rights reserved.