bootstrap带有进度条的密码强度检测插件

所属分类: 网页特效-表单验证    2023-12-24 09:29:23

 81.2K  5  查看评论 (3)
bootstrap带有进度条的密码强度检测插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

bootstrap带有进度条的密码强度检测插件(共3个文件)

    • index.html

使用方法

const passwordInput = document.getElementById('password-input');
const meterSections = document.querySelectorAll('.meter-section');

passwordInput.addEventListener('input', updateMeter);

function updateMeter() {
    const password = passwordInput.value;
    let strength = calculatePasswordStrength(password);

    // Remove all strength classes
    meterSections.forEach((section) => {
        section.classList.remove('weak', 'medium', 'strong', 'very-strong');
    });

    // Add the appropriate strength class based on the strength value
    if (strength >= 1) {
        meterSections[0].classList.add('weak');
    }
    if (strength >= 2) {
        meterSections[1].classList.add('medium');
    }
    if (strength >= 3) {
        meterSections[2].classList.add('strong');
    }
    if (strength >= 4) {
        meterSections[3].classList.add('very-strong');
    }
}

function calculatePasswordStrength(password) {
    const lengthWeight = 0.2;
    const uppercaseWeight = 0.5;
    const lowercaseWeight = 0.5;
    const numberWeight = 0.7;
    const symbolWeight = 1;

    let strength = 0;

    // Calculate the strength based on the password length
    strength += password.length * lengthWeight;

    // Calculate the strength based on uppercase letters
    if (/[A-Z]/.test(password)) {
        strength += uppercaseWeight;
    }

    // Calculate the strength based on lowercase letters
    if (/[a-z]/.test(password)) {
        strength += lowercaseWeight;
    }

    // Calculate the strength based on numbers
    if (/\\d/.test(password)) {
        strength += numberWeight;
    }

    // Calculate the strength based on symbols
    if (/[^A-Za-z0-9]/.test(password)) {
        strength += symbolWeight;
    }

    return strength;
}

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 表单验证

jquery多种字段类型的表单验证

超实用的表单验证插件,含:用户名、电话、密码、邮箱、网址、身份证等字段类型。
  表单验证
 9741  0

jquery带加载动画的表单验证特效代码

表单验证核心脚本validation文件,增加了自动填写表单信息功能,很实用!
  表单验证
 6762  0

jquery多种表单类型验证Vali.js插件

包含15种验证方式,可自定义提示框,可扩展性极强,有兴趣的大家可以研究!
  表单验证
 7801  0

jquery表单密码输入安全强度检测插件

根据特定条件计算密码的强度,并在带有自定义消息的视觉指示器工具提示中显示密码的质量。
  表单验证
 6834  0

评论数(3) 回复有机会获得K币 用户协议

    masker0
    2024-01-29 14:19:17
    Amireux0
    2024-01-11 15:06:02
    何处不逢杨0
    2024-01-05 14:09:08
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论