How to disable html input form field suggestions?

By suggestions, I mean that the drop-down menu appears when you enter text, and its suggestions are based on what you typed earlier:

Example

for example, when I type 'a' in the title field, it will give me a ton of sentences that are quite annoying. Does anyone know how to disable this? Thank you in advance.

+27
source share
4 answers

What you want is to disable the HTML autocomplete attribute.

Setting autocomplete = "off" here has two effects:

It does not allow the browser to save field data for subsequent autofill in similar forms, although heuristic parameters depend on the browser. It does not allow the browser to cache form data in the session history. When the form data is cached in the session history, the information filled in by the user will be visible after the user submits the form and clicks the "Back" button to return to the original form page.

Learn more about MDN

Here is an example of how to do this.

 <form action="#" autocomplete="on"> First name:<input type="text" name="fname"><br> Last name: <input type="text" name="lname"><br> E-mail: <input type="email" name="email" autocomplete="off"><br> <input type="submit"> </form> 

If it is on a React platform, use the following:

 <input id={field.name} className="form-control" type="text" placeholder={field.name} autoComplete="off" {...fields}/> 

Link to respond to documents

Refresh

Here's an update to fix some browsers skipping the "autocomplete = off" flag.

 <form action="#" autocomplete="off"> First name: <input type="text" name="fname" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');"><br> Last name: <input type="text" name="lname" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');"><br> E-mail: <input type="email" name="email" autocomplete="off" readonly onfocus="this.removeAttribute('readonly');"><br> <input type="submit"> </form> 
+33
source

In Chrome, the only way we could define that prevented all forms from filling out was to use autocomplete="new-password" . Apply this to any input that should not have autocomplete, and it will be applied (even if the field has nothing to do with passwords, for example, filling SomeStateId with SomeStateId form values). See this link in the discussion of Chromium errors for more details .

Please note that this only works stably in browsers based on Chromium and Safari - Firefox does not have special handlers for this new-password ( see details in this discussion ).

Update: Firefox is already on board! The nightly versions 6868a1 and Beta v67.0b5 (03/27/2009) support the autocomplete attribute new-password , stable releases should appear on 05/14/2009 in accordance with the roadmap .

+4
source

I ended up changing the input field to

 <textarea style="resize:none;"></textarea> 

You will never get auto-complete for texting.

+2
source

use attribute autocomplete="off"

Quote: IMPORTANT

Put the attribute in the <input> element, NOT in the <form> element

0
source

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


All Articles