键盘事件

        .setpsw {
            margin: 0 auto;
            height: 50px;
            overflow: hidden;
            display: inline-block;
        }

        .setpsw input {
            width: 30px;
            height: 30px;
            padding: 0 0;
            float: left;
            margin: 5px;
            text-align: center;
            line-height: 21px;
            border: 1px solid rgba(0, 0, 0, .2);
            border-radius: 3px;
            outline: 0;
            background-color: #fff;
        }
    </style>
 <div class="setpsw input">
        <input type="password">
        <input type="password">
        <input type="password">
        <input type="password">
        <input type="password">
        <input type="password">
    </div>
<script>
  $(".input input").keyup(function (event) {
            var e = (event) ? event : window.event;
            if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) {
                var value = $(this).val();
                var length = value.length;
                var val;
                if (length > 0.5) {
                    val = value.substring(length - 1, length);
                    $(this).val(val).next().focus()
                }
            } else if (e.keyCode == 8) {
                $(this).prev().focus()
            } else {
                var _val = this.value;
                this.value = _val.replace(/\D/g, '');
            }
        });
</script>
输入6位数字密码

显示输入字数及提示

    function(){
        var count=$(this).val().length;
        $("#textcount").html(count);
        if(count>70){
            $("#tip").show();
        }else{
            $("#tip").hide();
        }
    }
)
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容