How to disable the AutoComplete option

Hi,

In my Jsp application, whenever I open my Login Page and enter Id and Password, I get a dialog box 'AutoComplete' with follow mesg.

--Do you want Windows to remember this password, so that you

don't have to type it again the next time you visit this page?

--Don't offer to remember any more passwords

My question = How u disable this option at the client browser through your Jsp application, as I don't want to give the user this option.

I know that you can check the -Don't offer option, to avoid.

But, how you implement it by your Jsp app.

[601 byte] By [Suresh_hia] at [2007-10-3 1:29:58]
# 1

You can't affect the user browser settings.

However you can make it so that it won't pick up on this password field whatever the settings: Just specify "autocomplete=off" on the field you don't want it to save.

<input type="password" name="password" autocomplete="off">

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/forms/autocomplete_ovr.asp

evnafetsa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Does that work on all browsers or just IE?
tolmanka at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Good question. (Googles a little, Experiments with it a little)

It is a non-standard tag attribute.

http://developer.mozilla.org/en/docs/How_to_Turn_Off_Form_Autocompletion

This form attribute is not part of any web standards but was first

introduced in Microsoft's Internet Explorer 5. Netscape introduced it in

version 6.2 -- in prior versions, this attribute is ignored. The

autocomplete attribute was added at the insistance of banks and card

issuers -- but never followed through on to reach standards certification.

The page goes on to recommend use of the attribute anyway.

Found this page that says it doesn't always on some versions:

http://wssg.berkeley.edu/SecurityInfrastructure/reports/AutoComplete/index.html

Page used to test:

<form>

<h2>Form with autocomplete at default</h2>

<table>

<tr><td>User name</td><td><input type="text" name="user"></td></tr>

<tr><td>Password</td><td> <input type="password" name="password"></td></tr>

<tr><td colspan="2"><input type="submit"></td></tr>

</table>

</form>

<hr>

<form>

<h2>Form with autocomplete password switched off</h2>

<table>

<tr><td>User name</td><td><input type="text" name="user"></td></tr>

<tr><td>Password</td><td> <input type="password" name="password" autocomplete="off"></td></tr>

<tr><td colspan="2"><input type="submit"></td></tr>

</table>

</form>

<hr>

<h2>Form with autocomplete switched off at form level</h2>

<form>

<table>

<tr><td>User name</td><td><input type="text" name="user" autocomplete="off"></td></tr>

<tr><td>Password</td><td> <input type="password" name="password"></td></tr>

<tr><td colspan="2"><input type="submit"></td></tr>

</table>

</form>

Couple of interesting points to note:

With IE, if I said "no" saving the password, it still remembered the username, and the fact that I had previously said "no" to saving password. Had to keep using different user names to ensure it just wasn't "caching" username and my desire to not save password.

Firefox remember username/password when I navigated back to the page - as long as I got the master password right. IE only populated the password when I typed in the same username and auto-completed.

Well that was interesting.

Cheers,

evnafets

evnafetsa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
how to use it on html:text?
jgalacambraa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

Yeah, that one occurred to me to.

You can't directly, because the html:text component doesn't declare it as an attribute.

Alternatives: just use a manual <input type="text"> or more likely, <input type="password">

A more tricky javascript way, would be to dynamically set the variable with javascript after the page is loaded.

Neither way is optimal, but thats life.

evnafetsa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
thnx.. i think the javascript would be more appropriate for the elements to be in uniform format:)
jgalacambraa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
how would u do that with javascript. any sample script?
Suresh_hia at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
function autoCompOff(id){ document.getElementById(id).setAttribute("autocomplete","off");}This works in Firefox, it should work in IE but haven't been able to test it just yet.
Cobaltikusa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9
OK I've tested it in IE now and yes it works
Cobaltikusa at 2007-7-14 18:27:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...