How can a website developer disable autocomplete in forms?
-
- Posts: 10
- Joined: July 7th, 2005, 7:07 am
How can a website developer disable autocomplete in forms?
How can I design a web form that FireFox will not try to autocomplete?
For IE, I can add the parameter autocomplete="off" to either the <form> tag or the individual <input> tags but that doesn't disable autocomplete for FireFox.
What will?
Thank you.
For IE, I can add the parameter autocomplete="off" to either the <form> tag or the individual <input> tags but that doesn't disable autocomplete for FireFox.
What will?
Thank you.
- Vectorspace
- Moderator
- Posts: 14455
- Joined: November 27th, 2003, 4:50 am
- Location: Warwickshire, UK
- Contact:
Moving to Web Development - most users here are not web developers, so there will be more people who can help you there.
"All things being equal, the simplest answer is usually the correct one" - Occam's Razor
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
-
- Posts: 3451
- Joined: November 30th, 2002, 12:30 pm
- Nanobot
- Posts: 578
- Joined: April 28th, 2004, 7:25 pm
- Location: California
- Contact:
As a website developer, you shouldn't try to control the user's browser interface. Trying to do so will practically always require nonstandard code, can always be overridden, and is just annoying.
Web browser standards support tables
Internet Explorer is dangerous
Web Devout - Promote standards and the health of the Web
Internet Explorer is dangerous
Web Devout - Promote standards and the health of the Web
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
Nanobot wrote:As a website developer, you shouldn't try to control the user's browser interface. Trying to do so will practically always require nonstandard code, can always be overridden, and is just annoying.
I don't see anything wrong with autocomplete=off when used in certain situations such as:
a) Credit card number entry
b) Entry that would likely not be repeated (such as a call centre rep entering a caller's ID number)
c) Fields from the same server with the same name, but mean different things on different pages (ex: when a moderator wants to add a user, they don't want their own username to autocomplete)
-
- Posts: 10
- Joined: July 7th, 2005, 7:07 am
Nanobot wrote:As a website developer, you shouldn't try to control the user's browser interface. Trying to do so will practically always require nonstandard code, can always be overridden, and is just annoying.
In your opinion... But there are obviously circumstances you have not considered. For example, my situation:
I have 4 moderators on a phpBB forum I administer. I have installed the Moderator Control Panel so my moderators can edit user's information. The User Administration screen includes, among other things, the ability to change a user's User Name or reset a user's Password.
With FireFox's incorrect handling of this situation, the moderator's own username and password are incorrectly applied to the user's fields as soon as the page is loaded, potentially destroying a user account if not reset.
This isn't about trying to control a user's experience. This is about trying to resolve an issue FireFox incorrectly handles.
To automatically fill in the user's Username and Password on a login screen is fine. To do so on a data screen like this not only wrong, it is unacceptable. You are more likely to corrupt the data than save the user time.
In the future, Nanobot, it might be wise to understand what you are offering an opinion about. Your response not only didn't help with my question, it unnecessarily annoyed me. I need help with a technical problem, not a critique of my web design philosophy.
- jqp
- Posts: 5070
- Joined: November 17th, 2004, 10:56 am
- Location: In a box
- Contact:
Would it work to add a script to clear out text fields that are supposed to be empty?
That would only work if autocomplete happens BEFORE any onload events, and onload happens AFTER autocomplete... (it should, if I'm right...)
I agree - put autocomplete=off on the form element, too, for good measure.
Code: Select all
window.onload = function() {
inputs = document.getElementsByTagName("input");
for(var i = 0; i < input.length; i++) {
if(inputs[i].type == "text" || !input[i].getAttribute("type")) {
/* make this more specific to get only the inputs you want */
inputs[i].value = "";
}
}
}
That would only work if autocomplete happens BEFORE any onload events, and onload happens AFTER autocomplete... (it should, if I'm right...)
I agree - put autocomplete=off on the form element, too, for good measure.
-
- Posts: 10
- Joined: July 7th, 2005, 7:07 am
-
- Posts: 4941
- Joined: July 31st, 2003, 1:26 pm
Yes, this is a known bug (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=112260" title="Bug 112260 - Password manager silently overwrites form-supplied values">Suite</a>, <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=229762" title="Bug 229762 - If username field is prefilled by page to a value that matches a stored signon, pwmgr should prefill password">Firefox</a>). The alternative workaround to futzing with the autocomplete value would be to disallow Firefox from saving your username/password for the forum.
Last edited by Unarmed on July 13th, 2005, 2:29 pm, edited 1 time in total.
-
- Posts: 3826
- Joined: November 14th, 2004, 4:41 am
- Location: Alberta, Canada
- Contact:
Yes this is a constant pain in the arse on my phpbb forums as well... the PHPBB creator actually filed a bug in bugzilla about this lemme see if I can dig it up.
Edit: nm unarmed beat me to it.
Edit: nm unarmed beat me to it.
I'm moving to Theory, everything works there.
Most issues are solved by going through the Standard Diagnostic
Most issues are solved by going through the Standard Diagnostic
-
- Posts: 10
- Joined: July 7th, 2005, 7:07 am
Here's what I've implemented as a work around:
Add this script:
Add to the <form tag>:
Change the "username" and "password" field names to "temp_username" and "temp_password"
And add hidden fields to receive the values to be submitted:
So far, it's been working like a charm.
Add this script:
Code: Select all
<script language="JavaScript" type="text/javascript">
<!--
function FixFields()
{
document.usradm.username.value = document.usradm.temp_username.value;
document.usradm.password.value = document.usradm.temp_password.value;
}
// -->
</script>
Add to the <form tag>:
Code: Select all
name="usradm" onsubmit="FixFields()"
Change the "username" and "password" field names to "temp_username" and "temp_password"
Code: Select all
<input class="post" type="text" name="temp_username" size="35" maxlength="40" value="{USERNAME}"{DISABLE_CHANGE} />
<input class="post" type="password" name="temp_password" size="35" maxlength="32" value=""{DISABLE_CHANGE} />
And add hidden fields to receive the values to be submitted:
Code: Select all
<input type="hidden" name="username" value="" />
<input type="hidden" name="password" value="" />
So far, it's been working like a charm.