這是本文件的舊版!


Autocompletion problem on Firefox or Chrome

Problem

瀏覽器提供自動輸入的功能,如果是在登入畫面,就非常方便。如果是在修改資料的地方,就不一定這麼方便了。舉例來說,像新增使用者的功能,使用者預期的帳號密碼應該是空的,但瀏覽器卻會幫你填入它所記載的帳號密碼。

How to?

網路上提供的做法不乏是加入autocomplete=“off”,

<input type="text" autocomplete="off" name="name"/>
<input type="password" autocomplete="off" name="password"/>
後來試驗參考2的做法,只要加入隱藏的password輸入,就可以解決此問題。
<input type="text" autocomplete="off" name="name"/>
<input type="password" style="display: none"/>
<input type="password" autocomplete="off" name="password"/>

Reference