Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can't prevent browser to save password specially in Firefox.

What I have tried:

JavaScript
if (navigator.userAgent.indexOf('Firefox')!= -1)
            {
                $('form').attr("autocomplete", "off");
              
            }
            else {
                $('input[type="text"]').attr("autocomplete", "false");
                $('input[type="password"]').attr("autocomplete", "false");
            }
Posted
Updated 2-Dec-16 10:19am
Comments
F-ES Sitecore 2-Dec-16 4:14am    
It's up to the user if they want their browser to remember their password, not you.
Suvendu Shekhar Giri 2-Dec-16 9:37am    
Virtual 5!


For this reason, many modern browsers do not support autocomplete="off" for login fields:
...
This is the behavior in Firefox (since version 38), Google Chrome (since 34), and Internet Explorer (since version 11).

In other words, don't. Let the browser handle it.
 
Share this answer
 
Apart from what others have said, you can also try to use Ajax requests to submit the form, this way you will be able to send the details to server and browser won't intervene here.
JavaScript
$.ajax({
   data: {
      uname: $('#username').val(),
      upass: $('#pass').val()
   },
   success: function(response) {
      // Handle successful response
   }
});

Notice that I used IDs, instead of native type checking selection, this one looks clean. But this is just a quick hack and may not work in later versions of browsers. Also, this does not mean any plugins won't notice this.

Even this method fails sometime if you use POST requests with username/password to submit forms. I happen to see "Save password" dialog on Chrome (Firefox would do the same) for my Azure VMs, where page reloading and conventional submission is not at all a problem.

So, as mentioned in comments it is entirely in the hands of user.
 
Share this answer
 

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