How can I write my HTML login form to explicitly enable LastPass?
Asked Answered
J

2

13

How can I write my HTML login form to be guaranteed to work with LastPass, or at least make it as likely as possible to work? Some sites require the "Save All Entered Data" to work properly with LastPass, but as a site developer I'm looking for something better. What do I need to do to ensure LastPass default mode ("Save Site") works as flawlessly as possible? I can't find any official documentation, or really even any good blog posts with suggestions, but that would certainly answer my question. What does ideal or at least empirically successful markup look like?

Extra credit for (1) evidence and/or (2) a strategy that works across multiple password managers.

Josh answered 20/8, 2014 at 20:14 Comment(3)
I guess you should use common names for your inputs, like username and passwordWage
@Josh The comment from the official support statement should be a real answer as well including code example.Inextricable
Added answer, @VolkerE.Josh
P
3

I think most password manager try to get a clue for what a input field is meant for by examining the name attribute and the css class/id. I try to give my inputs names which a used by humans like username, password, city something like this. For the most password manager this has worked. Also Chrome's manager seems to understand it.

Preconcerted answered 20/8, 2014 at 20:27 Comment(1)
Thanks @Reflic. Based on empirical testing, name (and perhaps id) seems to matter the most, more than class. If you have an alternative name such as "email" LastPass seems to have trouble recognizing it regardless of the class. So <input name="username"... seems sufficient and probably necessary. I'd recommend <input name="username" class="username" id="username"... and <input name="password" class="password" id="password" type="password"... whenever developers have control over all those attributes.Josh
J
13

Finally found official support statement. Excerpt:

<form action="https://mypage.com/blah" method="post">
  <input type="text" name="username" id="username" value=""/>
  <input type="password" name="password" id="password" value=""/>
  <input type="submit" value="LOGIN"/>
</form>

This closely related question is also really helpful for general advice across all password managers.

Josh answered 21/8, 2014 at 21:4 Comment(2)
Btw, Login should be written 'Login', as you should care about styling via CSS. Thanks for the answer!Inextricable
For a form to change an existing password: I had to set the name of the existing password to old_password and then the new password and confirm password could be anything. (YMMV)Inapposite
P
3

I think most password manager try to get a clue for what a input field is meant for by examining the name attribute and the css class/id. I try to give my inputs names which a used by humans like username, password, city something like this. For the most password manager this has worked. Also Chrome's manager seems to understand it.

Preconcerted answered 20/8, 2014 at 20:27 Comment(1)
Thanks @Reflic. Based on empirical testing, name (and perhaps id) seems to matter the most, more than class. If you have an alternative name such as "email" LastPass seems to have trouble recognizing it regardless of the class. So <input name="username"... seems sufficient and probably necessary. I'd recommend <input name="username" class="username" id="username"... and <input name="password" class="password" id="password" type="password"... whenever developers have control over all those attributes.Josh

© 2022 - 2024 — McMap. All rights reserved.