Stop LastPass filling out a form

前端 未结 13 1706
遇见更好的自我
遇见更好的自我 2020-12-07 13:38

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

This is an hidden field,

相关标签:
13条回答
  • 2020-12-07 14:09

    Two conditions have to be met:

    1. The form (not the element) needs to have autocomplete="off" attribute
    2. Lastpass user needs to have this option enabled: Settings > Advanced > Allow pages to disable autofill

    So this depends on both user and the developer.

    0 讨论(0)
  • 2020-12-07 14:09

    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.

    0 讨论(0)
  • 2020-12-07 14:10

    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");
    }
    
    0 讨论(0)
  • 2020-12-07 14:11

    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.

    0 讨论(0)
  • 2020-12-07 14:12

    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.

    0 讨论(0)
  • 2020-12-07 14:12

    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.

    0 讨论(0)
提交回复
热议问题