Disable Firefox html autocomplete form but keep auto completion

In newer versions of Firefox, there is a new function that remembers the material that was filled in the form and re-fills the form with these values โ€‹โ€‹when updating (perhaps in other situations?).

The problem is that we have a rather complicated web application that uses a fair bit of ajax and hidden form fields that are never populated by the user, but javascript. Because of this new โ€œfunction,โ€ we get a lot of errors when updating the form, because these fields are unexpectedly filled with invalid values.

So I'm looking for a way to disable this feature without disabling autocomplete. (because it is useful for fields that are filled by our customers)

if i put

autocomplete='off'

in my html, the effect is disabled, but it loses autocomplete (obviously). the problem is filling in the fields after the update without any user action.

+4
source share
7 answers

While the password manager fills in the username and password, if there is exactly one match, autofill itself does not automatically fill in the fields. But I assume that you are thinking about what kind of update you get, say, when you reload the page. In this case, the field values โ€‹โ€‹are restored in the session history, but you can disable them by marking your page as unreadable.

+1
source

Well, you have to set the value of these fields with nothing or other default values โ€‹โ€‹that they have using javascript before you begin to perform other javascript / ajax tasks.

+1
source

This is a browser feature - without going into the settings of each client browser, you cannot disable it.

I offer a more reliable check - client and server.

0
source

After the page loads, but before you execute any other logic, you must force the value to be empty:

 inputElem.value = ''; 
0
source

Here is the jQuery solution I put together.

It does not disable autocomplete, but rather overrides the fields after the browser has done this.

I tried to fight Chromes autofill when I did this. Just using .val ('') on it own didn't work, as it worked before the chrome auto-fill feature hit it.

 var noFiller = $('input[type="text"]'); noFiller.val(' '); var t=setTimeout(function(){ noFiller.val(''); },60);//keep increasing this number until it works 
0
source

The Javascript solution has already been mentioned (the value of the installation field, which should be omitted when loading the page or updating via Ajax).

Another option would be to create identifiers for your fields with random numbers attached to them so that the browser cannot match them with cached values, but this can ruin other things.

0
source

Autocomplete is not news. Every browser has it. See http://www.w3.org/Submission/web-forms2/#the-autocomplete

Autofill? Are you sure? Test your input value attribute with Firebug (Firefox addon). Check the message and response in your ajax. Perhaps your ajax fills it behind the scenes.

BTW: remenber to disable any external toolbar. There are some toolbars for Firefox / IE / Chrome / etc that automatically populate data for the user. Warning with this.

-1
source

Source: https://habr.com/ru/post/1337961/


All Articles