关闭本地主机上的自动完成

Turn off autocomplete on local host

我在本地 WAMP 服务器上有一个基于 PHP 的基本网站 运行。

我正在尝试关闭表单的自动完成功能,但 运行 遇到了问题。

代码是:

但是没有用,是我的语法搞砸了吗?

谢谢韦恩

根据Mozilla Developer Network ...

The autocomplete attribute in a form typically has two effects.

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

但是,登录 username/password 字段需要注意,浏览器通常不会应用此字段。

Modern browsers implement integrated password management: when the user enters a username and password for a site, the browser offers to remember it for the user. When the user visits the site again, the browser autofills those login fields with the stored values.

因此,如果您通过选择记住该站点的登录信息将 username/password 登录信息保存在浏览器中,您可能仍会看到浏览器自动填充这些信息。

这里有一个 link for removing these saved logins from different browsers 可能会有帮助。

HTML5 没有自动完成功能,为什么不用Datalist? 您为 html 表单的输入指定可能值的列表。

修改表单元素以包含类型

<form list="cars" method="post" action="index.php" name="loginform" id="loginform">


<datalist id="cars">
  <option value="Ferrari">
  <option value="Lamborghini">
  <option value="Porsche">
  <option value="Maserati">
  <option value="Aston Martin">
</datalist> 

当然可以修改列表属性以满足您的需要。