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

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

 41.3K  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简单易用的会员注册表单验证插件

一款在线表单提交验证插件,提供了三种表单类型验证:用户名、密码、邮箱,可自定义非常方便扩展。
  表单验证
 3597  0

jquery会员注册表单验证

一款基于jquery多类型表单验证,包含了表单验证、生日下拉框选择、邮箱自动补全、密码可见性与重复密码的验证等,非常实用。
  表单验证
 6776  0

原生js实现的鼠标拖动滑块通过验证

一款javascript实现的滑块验证特效,常用于会员注册登录表单中,鼠标拖动滑块至最右侧可完成验证。
  表单验证
 4628  0

jquery网页底部右下角悬浮在线留言表单特效代码

一款网站右下角可展开的留言功能,带关闭隐藏按钮,已展开收缩。
  表单验证
 1776  0

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

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