Disable Firefox's Auto-fill
If the problem is that FF is populating the fields when the user refreshes, this is actually a feature of Firefox to try to help the user in the case of accidental refresh so they don't lose whatever they have typed. I don't think you can override this with the HTML. You could use JavaScript to clear/reset all the relevant form values on page load. If a form.reset() on the form doesn't work, you will have to iterate over the form elements and clear them like this:
for (i = 0; i < frm_elements.length; i++)
{
field_type = frm_elements[i].type.toLowerCase();
switch (field_type)
{
case "text":
case "password":
case "textarea":
case "hidden":
frm_elements[i].value = "";
break;
case "radio":
case "checkbox":
if (frm_elements[i].checked)
{
frm_elements[i].checked = false;
}
break;
case "select-one":
case "select-multi":
frm_elements[i].selectedIndex = -1;
break;
default:
break;
}
}
Remove new Firefox autofill color
Firefox 94 and newer
Just change the input's background color in your css:
input:autofill {
background: #fff; /* or any other */
}
If you wish to remove the autofill background only in your Firefox browser, set layout.css.autofill.background
to false
in about:config
.
Firefox 67 (2019-05-21) - 94 (2021-11-02; excluding)
Add this to your css:
input {
filter: none;
}
Why? At the bottom of view-source:resource://gre-resources/forms.css
we can see this:
:-moz-autofill, :-moz-autofill-preview {
filter: grayscale(21%) brightness(88%) contrast(161%) invert(10%) sepia(40%) saturate(206%);
}
And that is the cause of the yellow autofill background color.
How to disable autocomplete in Firefox using Selenium with Python?
You need to set browser.formfill.enable
firefox profile preference to false
to ask Firefox not to remember and autofill form input values:
profile.set_preference("browser.formfill.enable", "false")
Turn off autocomplete in FireFox
put a hidden empty text field between username and password
<input type="text" name="username">
<!-- disables autocomplete --><input type="text" style="display:none">
<input type="password" name="password">
How can I prevent Firefox's Autocomplete?
Add autocomplete="off" to your form tag, as documented in the Mozilla document How to Turn Off Form Autocompletion
<form name="form1" id="form1" method="post" autocomplete="off"
action="http://www.example.com/form.cgi">
[...]
</form>
Do read the section on exceptions and workarounds though - the browser will ignore the autocomplete attribute if you have a Name or Address field in the form!
How do you disable browser autocomplete on web form field / input tags?
Firefox 30 ignores autocomplete="off"
for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following commentary from May 5, 2014:
- The password manager always prompts if it wants to save a password. Passwords are not saved without permission from the user.
- We are the third browser to implement this change, after IE and Chrome.
According to the Mozilla Developer Network documentation, the Boolean form element attribute autocomplete
prevents form data from being cached in older browsers.
<input type="text" name="foo" autocomplete="off" />
Related Topics
Webgl - Wait for Texture to Load
How Can Change Width of Dropdown List
How to Hide The Arrow That Is Displayed by Default on The HTML5 <Details> Element in Chrome
Export Stored Procedure Result Set to Excel in Ssms
CSS Align Images and Text on Same Line
Clear Canvas Rect (But Keep Background)
HTML5 Autoplay Video in Mobile Device
CSS to Keep Element at "Fixed" Position on Screen
Use The HTML <Img> Tag as a Background Image Instead of The CSS Background-Image Property
Bootstrap 4: Center Inline Form Inside a Jumbotron
Is It Possible Put Image in Input Type="Check Box"
Sticky Header and Footer Scrollable Content
HTML - Why Boolean Attributes Do Not Have Boolean Value
How to Make Children Auto Fit Parent's Width Only with CSS
What Does The Shrink-To-Fit Viewport Meta Attribute Do