jq密码验证正确性

12 篇文章 0 订阅
7 篇文章 0 订阅

验证密码的正确性

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .show {
                padding: 20px;
                display: none;
            }

            em {
                font-style: normal;
                color: #ff6600
            }
            ul li{
                width: 50px;
                height: 50px;
                border:1px solid red; 
                float: left;
                list-style: none;
            }
            ul li{
                border-right: none;
               font-size: 50px;
               line-height: 10px;
               text-align: center;
            }
             ul li:nth-child(6){
                border-right:1px solid red;
             }
             .clearfix:after{
                height: 0;
                content: '';
                display: block;
                height: 0;
                font-size: 0;
                visibility: hidden;
                clear: both;
             }
             /*input{
                height: 1;
                opacity: 0;
                width: 1;
                border: none;
             }*/
             body{
                height: 3000px;
             }
    </style>
</head>
<body>
<label for="inp">
    <ul class="clearfix">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</label>
<input type="tel" name="" id="inp" maxlength="6">
<div class="show">呵呵<span></span></div>  
<div class="back" style="position:fixed; bottom: 0;">回顶部</div>  
</body>
<script type="text/javascript" src="jquery-1.12.3.js"></script>
<script type="text/javascript">
    $('#inp').on('input',function(){
        var num = 6;
        var vr = $('#inp').val();
        var list = $('li');
        /*$("#inp").focus();*/
        $('span').text($('#inp').val());
        for (var i = 0; i<num; i++) {
            if (vr[i]) {
                $(list[i]).text('.')
            }else{
                $(list[i]).text('')
            }
        }
        if ($('span').text().length==6){
            if ($('span').text()== '123456') {
                alert('密码正确')
            }else{
                alert("密码错误")
            }
    }
    })
    $(window).scroll(function(){
      $('.back').click(function(){
        document.body.scrollTop = 0
      })
    })
</script>
</html>

效果图如图所示这里写图片描述这里写图片描述]![这里写图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值