How to turn off html input form field suggestions?

前端 未结 8 1372
难免孤独
难免孤独 2021-01-31 07:20

By suggestions I mean the drop down menu appear when you start typing, and it\'s suggestions are based on what you\'ve typed before:

for example when I type \'a

8条回答
  •  暖寄归人
    2021-01-31 07:39

    What you want is to disable HTML autocomplete Attribute.

    Setting autocomplete="off" here has two effects:

    It stops the browser from saving field data for later autocompletion on similar forms though heuristics that vary by browser. It stops the browser from caching form data in session history. When form data is cached in session history, the information filled in by the user will be visible after the user has submitted the form and clicked on the Back button to go back to the original form page.

    Read more on MDN Network

    Here's an example how to do it.

    First name:
    Last name:
    E-mail:

    If it's on React framework then use as follows:

    
    

    Link to react docs

    Update

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

    First name:
    Last name:
    E-mail:

提交回复
热议问题