![](/img/trans.png)
[英]How I can make text field behave like password field through input masking?
[英]How can I make the text entered into the username field copy to the password field so they are the same?
我知道这很容易,但是我想使密码和用户名一样自动输入,但是我无法实时复制它。
<%=I18n._("Username")%>:</td>
<td><%data.printTextField(out,UserPerson.FIELD_NAME,null,"text",100,0);%></td>
</tr>
<tr style="<%=data.isFacebook ? "display: none" : "" %>">
<td class="nowrap fieldheader"><span class="note-fieldrequired">*</span> <%=I18n._("Password")%>:</td>
<td><%data.printPasswordField(out,UserPerson.FIELD_PASSWORD,null,"password",100,0);%></td>
</tr>
假设您有一个用户名字段和一个密码字段,如下所示:
<input type="text" id="input-username">
<input type="password" id="input-password">
您必须将事件监听器附加到用户名字段(使用JavaScript ),例如:
const inputUsername = document.getElementById('input-username');
const inputPassword = document.getElementById('input-password');
inputUsername.addEventListener('keyup', function () {
inputPassword.value = inputUsername.value
})
但是,问问自己:您真的需要这样做吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.