简体   繁体   中英

HTML/CSS/JS: How to force browser to save password from a non-'password' type input?

The thing is that I have two values which are similar to a username and password, but are actually 2 randomly generated GUID's that users use to login to a website I made - they are not really a username and password, but with the GUIDs I try to replicate this combination.

Usually browsers ask you if you want to save the provided login values when seeing the type='password' attribute for an element. However, a type='password' attribute would make typing a GUID in a field rather difficult, since you can't see what you are typing.

So, how would you force or trick the browser to save a username/password combination without using the type="password" attribute?

Thanks!

What if you save a cookie on the client side, maybe with the text encrypted and when the user comes back to the site you first look if he has a cookie saved? Of course, it's a workaround and the cookie won't be there forever, but it's an option.

I'm also thinking you might make a CSS-hidden password input and copy the content to that before submiting the form, but I'm not sure that that tricks the browser.

我认为一个cookie是最简单的解决方案......至少在你能找到更好的东西之前......对于Claudiu的回答+1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM