首页 > 解决方案 > 当我们每次都关注输入字段时,如何在移动设备上触发数字键盘?

问题描述

我有一种情况,我需要将我的输入类型定义为“密码”,以便在输入字符时隐藏它们。但它需要表现得像数字。它用于 SSN 输入字段。我该怎么做?

<input id="ssn" type="tel" class="ssnentry form-control" value=""/>

$(".ssnentry").on("blur", function () {
            $(this).attr("type", "password");
            }).on("focus", function () {
            $(this).attr("type", "tel");
        });

每次输入字段被聚焦时,应该触发移动(ios)上的数字键盘。第一次尝试时,触发数字键盘。但是对于接下来的所有尝试,都会触发字母键盘。如何解决这个问题?

标签: jqueryhtml

解决方案


推荐阅读