autocomplete = 'off' is not working on firefox

后端 未结 17 1735
無奈伤痛
無奈伤痛 2020-12-17 09:25

I created 2 login pages of same domain.

  1. www.example.com/login.cfm
  2. www.example.com/newLogin.cfm

I put the form name different for 2 forms

相关标签:
17条回答
  • 2020-12-17 09:48

    I was encountered this issue for a long time. Firefox was kept input values even page reload. Setting autocomplete attribute to off did not solve.

    Form caching is a really useful mechanism for the user experience. But, in the small percentage of use-cases like translating values of textboxes or texareas to other language, these gave me headache.

    To resolve this, just simply reset the form after page was loaded as

     $('form').trigger("reset");
    
    0 讨论(0)
  • 2020-12-17 09:52

    thanks to the idea of albert.garipov, i made a solution that mimics the functionality of the type password. this doesn't show the password on input

    <input type="text" id="password" onkeyup="OnChangePassword()">
    

    function OnChangePassword()
    { 
      if ($("#password").val() == "") {
          $("#password").attr('type', 'text');
      }
      if ($("#password").val() != "") {
          $("#password").attr('type', 'password');
      }
    }
    
    0 讨论(0)
  • 2020-12-17 09:58

    This is the cleanest solution I have found to keep Firefox from auto completing.

     <!-- The text and password here are to prevent FF from auto filling my login credentials because it ignores autocomplete="off"-->
     <input type="text" style="display:none">
     <input type="password" style="display:none">
    

    Add this code snip-it above your input of type password.

    As far as I can tell Firefox is looking for an input of type Password, and filling in the password and then adding the username to the input of type text above it. Without a name or an id the inputs don't get added to the post, but this is still a hack.

    0 讨论(0)
  • 2020-12-17 10:02

    Use autocomplete="off" tag at the end of your input tag:

    For ex.

    <input type="text" name="username" autocomplete="off" />
    
    0 讨论(0)
  • 2020-12-17 10:02

    Add autocomplete="off" to your form tag, as documented in the Mozilla document

    Check the following link for more information

    How to Turn Off the Autocompletion Feature

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