简体   繁体   English

当输入类型=密码时,如何确保立即进行值屏蔽,而不会在电话上造成延迟?

[英]How to ensure value masking happens immediately when input type = password, without delay on a phone?

I'm working on a project wherein I have 5 input boxes of type password and after every input has been entered, the control goes to the next box. 我正在一个项目中,我有5个类型为password的输入框,输入完每个输入后,控件转到下一个框。

But only after 3 or 4 inputs have been entered, are the previous digits getting masked. 但是只有输入3或4个输入后,才会掩盖以前的数字。 There is a delay of about 3-4 seconds only after which the key is getting masked. 只有在大约3-4秒的延迟之后,密钥才会被屏蔽。

Initially, I thought that it might be because of the keydown/keyup functions linked to the input boxes, but the masking delay is happening even after I removed all key events. 最初,我认为这可能是由于链接到输入框的keydown / keyup函数引起的,但是即使删除了所有按键事件,屏蔽延迟仍在发生。

One thing I noticed was the same issue isn't occurring on a desktop, but it's happening only on mobile. 我注意到的一件事是,同一问题不在台式机上发生,而是仅在移动设备上发生。

 <div class="pin-div" id="form-group-id"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" id="pin-a"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" disabled="disabled" id="pin-b"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" disabled="disabled" id="pin-c"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" disabled="disabled" id="pin-d"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" disabled="disabled" id="pin-e"> <input name="pin" class="pin-inp" tabindex="0" type="password" maxlength="1" pattern="[0-9]*" inputmode="numeric" autocomplete="off" disabled="disabled" id="pin-f"> </div> 

The same delay in masking the digits is happening even after I used input type = "tel" 即使我使用input type =“ tel”,也发生了相同的数字掩盖延迟

What is the best way to ensure that there is no delay in masking inputs? 确保屏蔽输入没有延迟的最佳方法是什么?

Why isn't it occurring on a desktop device? 为什么它不在台式机设备上发生?

Because it's harder to type on a phone, where you're covering a tiny on-screen keyboard with your fingers which tries to make a best guess estimation where your meat nubs intended to hit the screen most likely. 因为在手机上打字比较困难,所以您用手指覆盖了一个很小的屏幕键盘,从而试图做出最佳猜测,以估计肉块最有可能击中屏幕的位置。 You pretty much need the visual confirmation to ensure you didn't mistype that key. 您几乎需要视觉确认,以确保您没有键入错误的密钥。 It's the default behaviour of the phone, for those reasons. 由于这些原因,这是手机的默认行为。

Typing on a large physical keyboard on a desktop device has none of those issues and the visual feedback isn't as necessary. 在台式设备上的大型物理键盘上键入不会出现这些问题,并且视觉反馈不是必需的。 It's also a lot easier to cover a tiny phone screen by simply turning away for a second than it is to do the same thing on a desktop device. 与在台式机设备上做相同的事情相比,只需将屏幕转小一点就可以覆盖一个很小的电话屏幕。

This is the way mobile browsers currently handle password inputs, accounting for both security and usability issues which obviously have different challenges compared to non-mobile browsers. 这是移动浏览器当前处理密码输入的方​​式,考虑了安全性和可用性问题,与非移动浏览器相比,这些问题显然面临不同的挑战。

Please see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password 请参阅https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password

Specifics of how the entry process works may vary from browser to browser; 各个浏览器的输入过程如何进行,具体细节可能有所不同; mobile devices, for example, often display the typed character for a moment before obscuring it, to allow the user to be sure they pressed the key they meant to press; 例如,移动设备经常在打出键入的字符之前先显示一会儿,以使用户确定自己按下了要按的键; this is helpful given the small size of keys and the ease with which the wrong one can be pressed, especially on virtual keyboards. 鉴于键的尺寸小并且可以轻松按错键(特别是在虚拟键盘上),这很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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