打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
手机端密码框
<!DOCTYPE html>  
<html>  
<head>  
<script src="//zeptojs.com/zepto.min.js"></script>  
  <title>手机端六位密码输入</title>  
<style>  
.pwd-box{  
        width:310px;  
        padding-left: 1px;  
        position: relative;  
        border: 1px solid #9f9fa0;  
        border-radius: 3px;  
over-flow:hidden  
    }  
    .pwd-box input[type="tel"]{  
        width: 99%;  
        height: 45px;  
        color: transparent;  
        position: absolute;  
        top: 0;  
        left: 0;  
        border: none;  
        font-size: 18px;  
        opacity: 0;  
        z-index: 1;  
        letter-spacing: 35px;  
    }  
    .fake-box input{  
        width: 44px;  
        height: 48px;  
        border: none;  
        border-right: 1px solid #e5e5e5;  
        text-align: center;  
        font-size: 30px;  
    }  
    .fake-box input:nth-last-child(1){  
        border:none;  
    }  
</style>  
</head>  
<body>  
<div class="pwd-box">  
    <input type="tel" maxlength="6" class="pwd-input" id="pwd-input">  
    <div class="fake-box">  
        <input type="password" readonly="">  
        <input type="password" readonly="">  
        <input type="password" readonly="">  
        <input type="password" readonly="">  
        <input type="password" readonly="">  
        <input type="password" readonly="">  
    </div>  
</div>  
<script>  
var $input = $(".fake-box input");  
            $("#pwd-input").on("input", function() {  
                var pwd = $(this).val().trim();  
                for (var i = 0, len = pwd.length; i < len; i++) {  
                    $input.eq("" + i + "").val(pwd[i]);  
                }  
                $input.each(function() {  
                    var index = $(this).index();  
                    if (index >= len) {  
                        $(this).val("");  
                    }  
                });  
                if (len == 6) {  
                    //执行其他操作  
                }  
            });  
</script>  
</body>  
</html> 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Ajax应用研究-注册应用
基于jQuery-ui实现多滑块slider
用js写简单选项卡 加 自动切换效果
用JS实现随机链接
完美的1px的文本输入框
复选框 select添加checkbox
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服