浏览器登录自动完成

vol*_*lna 7 html javascript browser forms autocomplete

我已经为用户可以拥有不同帐户类型的网站实现了登录,例如:

A型(默认)

Username: characters and numbers
Password: characters and numbers
Run Code Online (Sandbox Code Playgroud)

B型(序列号)

Username: only numbers, min 10
Password: characters and numbers
Run Code Online (Sandbox Code Playgroud)

当用户访问登录表单时,首先允许他/她选择他们想要使用的登录类型,然后他们继续进行实际登录.

问题前提条件
用户已Offer to save passwords启用本机并已保存登录的凭据Type AType B凭据,然后注销并最终再次尝试登录.

"问题":
当用户将选择Type A登陆,将重点放在用户名,浏览器会建议prefil领域,但两者Type AType B 会被浏览器提示.

问题
有没有办法以某种方式标记凭据在保存时的时间点,以便下次浏览器只建议相应的凭据.

PS:任何其他可能的解决方案或有价值的信息更受欢迎:)

更新 检查规格后:https:
//html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill


我已经添加autocomplete="section-uniqueGroupName"并确保了nameid是唯一的.


用户名登录

<form>
<input type="text" name="login-userName" id="login-userName" autocomplete="section-userName">
<input type="password" name="password-userName" id="password-userName" autocomplete="section-userName>
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)

使用卡号登录

<form>
<input type="text" name="login-serviceCard" id="login-serviceCard" autocomplete="section-serviceCard">
<input type="password" name="password-serviceCard" id="password-serviceCard" autocomplete="section-serviceCard>
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)

但它仍然似乎没有成功...在此输入图像描述

因此,调查仍在继续,这让我想知道实际上是否可以仅使用本机方法html attributes而不涉及JS实现以下内容:
1.按登录类型分隔用户凭据
2.和(或至少)自动填充上次使用的所选类型凭据登录

如果它实际上是可能的并且在网络上有一个活着的例子,那么我们将非常感激能够看一看:鞠躬:

小智 1

如果您对 A 型和 B 型输入进行不同的命名,浏览器将知道这是不同的输入,并根据用户选择的输入给出建议。