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

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

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

jquery弹出层显示实时输入密码检测规则插件

一款实时密码检测工具插件,可根据自定义密码规则,在线实时检测当前输入的密码是否符合规范。
  表单验证
 97  

jquery表单验证插件EasyValidator,超级简单易用!

一款实用的在线表单验证插件,含:用户名、中文名、邮箱、电话、上传文件等字段。
  表单验证
 162  

原生js在线留言表单验证代码

使用了正则验证email和phone手机号码,初学者可以下载学习!
  表单验证
 167  

jquery自定义文本文字传递到DIV并显示插件

一款onclick时间传递文本内容到指定DIV元素显示,非常的高效实用。
  表单验证
 136  

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

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