5

Let's say I have a login form like this:

 <form>
   <input type="email">
   <input type="password">
 </form>

Google Chrome (and other browsers) are able to offer saving my email and password without any problems. Also Chrome autofills this kind of form on page load without any problems.

I need to develop a feature, that "remembers" last user via localstorage and shows some fancy UI that also includes their name and email and only asks for password this time:

 <div>Welcome our old customer Umut (remembered@email.com)</div> 
 <form>
   <input type="hidden" value="remembered@email.com">
   <input type="password">
 </form>

This time, Chrome doesn't autofill password on pageload but when user focus into this field, they get a choice of users first:

demo

I wonder, if there is a way to tell browser that, I already have an email selected, and I want password for that email to be autofilled on page load.

Cross browser if possible.

PS. If I don't use hidden type on email, instead only make it invisible to user (using display:none), Chrome autofills both email and password. This means that, an invisible email filed is overriden by the value Google Chrome 'remembered'. So even you see remembered@email.com as fancy custom design, both email and password are modified by Chrome.

Umut Benzer
  • 3,476
  • 4
  • 36
  • 53
  • I wonder if that drop-down created by Chrome is part of the DOM. That way you can manipulate it with JavaScript. – andreini Sep 07 '16 at 11:19
  • 1
    It's definitely not part of the DOM, as that would be a major security flaw. Personally, I disagree with hiding or disabling the email field at all. It should be visible and editable every time you log on, otherwise no-one else can ever log on at that machine. If that's what you're actually looking for then you should be using a different type of authentication, like SSO (for example). – Reinstate Monica Cellio Sep 07 '16 at 11:23
  • @Archer The normal login form is available via a "Not Umut?" button. As a user I also prefer to see email input all the time but for the scope this question, it is not up to me. :/ – Umut Benzer Sep 07 '16 at 11:26
  • I seriously doubt you'll find a way to manipulate this, as it's browser dependent. It's even version dependent as different versions of different browsers will do different things. If it's not up to you then you need to tell the person that has made the decision that they're wrong. – Reinstate Monica Cellio Sep 07 '16 at 11:28

0 Answers0