Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

html - Disable Firefox's Auto-fill

Is it possible to disable Firefox's auto-fill feature without disabling auto-complete?

I know I can do this:

autocomplete="off"

But I don't want to disable auto-complete, just the auto-fill.

Firefox is populating some of our hidden fields which are meant to be empty

This is mostly a problem when the user refreshes the page. The form fields are re-populated with values from pre-refresh. An example of this being a problem is old-school place-holder. Where we populate the field with a value, and remove it on submit. The value is re-populated on refresh and we don't know if it's the place-holder or use value.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Putting two dummy fields in between the actual username field and the actual password field worked for me, e.g.:

<input name = "Username" type="text" autocomplete="off">
<input name = "DummyUsername" type="text" style="display:none;">
<input name = "DummyPassword" type="password" style="display:none;">
<input name = "Password" type="password" autocomplete="new-password">

This prevented the autofill of the username, as well as the autofill of the password.

autocomplete="new-password" is apparently not fully implemented, but can help with some browsers. I doubt that it was helpful with FireFox, but it is there for future versions in case the feature is more widely adopted.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...