kal*_*azy 20 html passwords input numeric
我知道这件事:
<input type="tel">
Run Code Online (Sandbox Code Playgroud)
我知道这件事:
<input type="password">
Run Code Online (Sandbox Code Playgroud)
但我想同时使用两者.我希望数字小键盘出现在iOS(特别是)上,但在输入后隐藏每个字符.这样的事情可能吗?
<input type="tel|password">
Run Code Online (Sandbox Code Playgroud)
mar*_*rco 15
对于iOS,您可以设置输入以键入"password",并仍使用HTML5-Attribute"模式"触发数字键盘:
<input type="password" pattern="[0-9]*" ... />
Run Code Online (Sandbox Code Playgroud)
要显示数字键盘,请将pattern属性的值设置为"[0-9] "或"\ d ".
输入框的Html:
<input type="tel" name="password" id="password" value="" placeholder="Enter password"
onfocus="changeToPassword()">
Run Code Online (Sandbox Code Playgroud)
使用Javascript:
// change the type of the input to password
function changeToPassword() {
setTimeout(function () {
document.getElementById("password").setAttribute("type", "password")
}, 500);
}
Run Code Online (Sandbox Code Playgroud)
这个解决方案适用于iPhone.这是一种黑客行为.一旦你在接下来的500毫秒内有了数字键盘,你就可以将attribut更改为密码,这会欺骗手机.
您可以将输入类型设置为密码,然后使用 javascript 验证按下提交按钮时是否仅输入了数字。 http://www.configure-all.com/javascript_form_validation.php
归档时间: |
|
查看次数: |
24334 次 |
最近记录: |