原生js+css实现密码输入隐藏显示切换及强度验证示例代码

代码语言:html

所属分类:验证

代码描述:原生js+css实现密码输入隐藏显示切换及强度验证示例代码定义皮肤支持关灯模式的h5视频播放器效果代码

代码标签: 原生 js css 密码 输入 隐藏 显示 切换 强度 验证 示例 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <style>

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-image: linear-gradient(to left bottom,#d87a00,#f46246,#fa557c,#e75eaf,#bc74d7,#9487eb,#6197f4,#00a3f3,#00afed,#00b9e0,#00c0cf,#2ac6bc);
    background-size: 200%;
    animation: bgAnimation 30s linear infinite;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none
}

@keyframes bgAnimation {
    0% {
        background-position: 0 50%
    }

    50% {
        background-position: 100% 50%
    }

    100% {
        background-position: 0 50%
    }
}

.box {
    position: relative;
    width: 400px;
    padding: 20px;
    border-radius: 10px;
    background-color: #fffa6
}

.box .inputBox,.box .checkinputBox {
    position: relative;
    width: 100%;
    background: #fff;
    padding: 5px;
    border-radius: 10px;
    box-shadow: 0 15px 25px rgba(0,0,0,0.15)
}

.box .checkinputBox {
    margin-top: 10px
}

.box .inputBox input,.box .checkinputBox input {
    position: relative;
    width: 100%;
    outline: 0;
    border: 0;
    padding: 10px 5px
}

.box .inputBox #toggleBtn,.box .checkinputBox #toggleBtn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 34px;
    height: 34px;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center
}

.box .inputBox #toggleBtn::before,.box .checkinputBox #toggleBtn::before {
    content: "o.O";
    font-family: fontAwesome
}

.box .inputBox #toggleBtn.hide::before,.box .checkinputBox #toggleBtn.hide::before {
    content: "-.-";
    font-family: fontAwesome
}

.validation {
    padding: 20px;
    margin-top: 10px;
    border-radius: 10px;
    background-color: #fffda;
    box-shadow: 0 15px 25px rgba(0,0,0,0.15);
    transition: all .3s ease-in-out
}

.validation ul {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px
}

.validation ul li {
    position: relative;
    list-style: none;
    color: #000;
    font-size: .85em;
    transition: .5s
}

.validation ul li.valid {
    color: #03d16e
}

.validation ul li::before {
    content: "✦";
    width: 20px;
    height: 10px;
    font-family: fontAwesome;
    color: #d15503;
    display: inline-flex
}

.validation ul li.valid::before {
    content: '✔';
    font-family: fontAwesome;
    color: #03d16e
}


   </style>
    </head>
    <body>
        <div class="box">
            <div class="inputBox">
                <input type="password" id="pswrd" placeholder="密码" onkeyup="checkPassword(this.value)">
                <span id="toggleBtn"></span>
            </div>
            <div class="checkinputBox">
                <input type="password" id="pswrd" placeholder="确认密码" onkeyup="recheckPassword.........完整代码请登录后点击上方下载按钮下载查看

网友评论0