Is there a W3C valid way to disable autocomplete in a HTML form?

后端 未结 18 1112
心在旅途
心在旅途 2020-11-22 05:58

When using the xhtml1-transitional.dtd doctype, collecting a credit card number with the following HTML



        
18条回答
  •  终归单人心
    2020-11-22 06:27

    autocomplete="off" this should fix the issue for all modern browsers.

    [...]

    In current versions of Gecko browsers, the autocomplete attribute works perfectly. For earlier versions, going back to Netscape 6.2, it worked with the exception for forms with "Address" and "Name"

    Update

    In some cases, the browser will keep suggesting autocompletion values even if the autocomplete attribute is set to off. This unexpected behavior can be quite puzzling for developers. The trick to really forcing the no-autocompletion is to assign a random string to the attribute, for example:

    autocomplete="nope"
    

    Since this random value is not a valid one, the browser will give up.

    Documetation

提交回复
热议问题