Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
3.12/5 (3 votes)
How to prevent browser from storing my username & password? I want the user to enter them everytime he login.

Username & Password are TextBoxes
Posted
v3
Comments
Bojjaiah 1-Nov-13 9:28am    
prevent cookies or ..?

1 solution

Solution

Use autocomplete="off" on those fields or on form.


Refer

1. ASP.NET – Disable saving of password / user name[^]

2. Disable browser 'Save Password' functionality[^]
Quote:
I'm not sure if it'll work in all browsers but you should try setting autocomplete="off" on the form.
HTML
<form id="loginForm" action="login.cgi" method="post" autocomplete="off">

Quote:
The easiest and simplest way to disable Form and Password storage prompts and prevent form data from being cached in session history is to use the autocomplete form element attribute with value "off".

From http://developer.mozilla.org/En/How_to_Turn_Off_Form_Autocompletion[^]

Some minor research shows that this works in IE to but I'll leave no guarantees ;)

@Joseph: If it's a strict requirement to pass XHTML validation with the actual markup (don't know why it would be though) you could theoretically add this attribute with javascript afterwards but then users with js disabled (probably a neglectable amount of your userbase or zero if your site requires js) will still have their passwords saved.

Example with jQuery:
JavaScript
$('#loginForm').attr('autocomplete', 'off');

Note:
Quote:
Just a quick comment, since this is changing, HTML5 adds the autocomplete attribute to the spec, so it is valid now.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 1-Nov-13 9:50am    
5ed.
—SA
Thanks a lot Sergey Alexandrovich Kryukov... :)
[no name] 1-Nov-13 10:05am    
Thanks it works.

autocomplete="off"


I tried it on FireFox 24.0, Chrome 30.0.1599.101 & IE9. Do you think it will work on earlier versions?
Not sure. But you should use this as it is supported by newer versions. :)
[no name] 1-Nov-13 10:31am    
Do you belive that some users are still using windows xp?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900