我意识到了这一点:如何使输入字段同时输入数字和密码?
<input type="tel">
,我意识到这一点:
<input type="password">
但我想同时使用。我想让数字小键盘在iOS上出现(特别是),但在键入后隐藏每个字符。是这样的可能吗?
<input type="tel|password">
我意识到了这一点:如何使输入字段同时输入数字和密码?
<input type="tel">
,我意识到这一点:
<input type="password">
但我想同时使用。我想让数字小键盘在iOS上出现(特别是),但在键入后隐藏每个字符。是这样的可能吗?
<input type="tel|password">
您可以输入输入密码,然后使用javascript验证在按下提交按钮时仅输入了数字。 http://www.configure-all.com/javascript_form_validation.php
这也是我的回答,但似乎OP希望启用一些通常由'type =“tel”'触发的特定于iOS的UI功能。我不认为JS输入验证将有助于这一点。 – 2012-01-15 21:55:53
答案链接不再有效。什么是更新的链接来帮助? – Whitecat 2017-10-24 18:28:08
输入框的HTML:
<input type="tel" name="password" id="password" value="" placeholder="Enter password"
onfocus="changeToPassword()">
的Javascript:
// change the type of the input to password
function changeToPassword() {
setTimeout(function() {
document.getElementById("password").setAttribute("type", "password")
}, 500);
}
此解决方案适用于iPhone上。这是一种黑客。一旦你在接下来的500毫秒内拥有数字键盘,你可以将attribut更改为密码,并且可以欺骗手机。
这不会再工作。在有人输入信息并模糊并尝试重新输入信息后,现在该类型已设置为密码,数字键盘不会来。 – Fyre 2014-10-14 03:55:46
在iOS设备上,你可以设置输入输入“密码”,并使用HTML5的属性还是触发数字键盘的“模式”:
<input type="password" pattern="[0-9]*" ... />
要显示数字键盘,将pattern属性的值设置为“[0-9] ”或“\ d”。
这应该是你的工作:http://stackoverflow.com/a/8334379/947898。 – uadrive 2012-01-15 18:38:39