限时优惠活动
亲爱的苦力吧用户,我们为了回馈新老用户一直以来的鼎力支持,即日起(2025-02-06至2025-03-06)凡是购买苦力吧VIP/充值K币的新老用户,都直接可获得买一送一的优惠馈赠。例如:购买一个月的VIP会员可直接获得两个月的VIP会员;充值100K币可直接获得200K币,以此类推!有任何疑问可联系在线客服,感谢各位用户对苦力吧素材的信任与厚爱,我们将一如既往的给大家上新更多优质的素材源码,祝大家开工大吉、工作顺利、心想事成。

js表单输入密码在线检验插件

所属分类: 网页特效-表单验证    2024-12-02 08:48:05

js表单输入密码在线检验插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

js表单输入密码在线检验插件(共3个文件)

    • script.js
    • index.html
    • style.css

使用方法

  • code
  • source
  1. const passwordInput = document.querySelector(".pass-field input");
  2. const eyeIcon = document.querySelector(".pass-field i");
  3. const requirementList = document.querySelectorAll(".requirement-list li");
  4. // An array of password requirements with corresponding
  5. // regular expressions and index of the requirement list item
  6. const requirements = [
  7. { regex: /.{8,}/, index: 0 }, // Minimum of 8 characters
  8. { regex: /[0-9]/, index: 1 }, // At least one number
  9. { regex: /[a-z]/, index: 2 }, // At least one lowercase letter
  10. { regex: /[^A-Za-z0-9]/, index: 3 }, // At least one special character
  11. { regex: /[A-Z]/, index: 4 }, // At least one uppercase letter
  12. ]
  13. passwordInput.addEventListener("keyup", (e) => {
  14. requirements.forEach(item => {
  15. // Check if the password matches the requirement regex
  16. const isValid = item.regex.test(e.target.value);
  17. const requirementItem = requirementList[item.index];
  18. // Updating class and icon of requirement item if requirement matched or not
  19. if (isValid) {
  20. requirementItem.classList.add("valid");
  21. requirementItem.firstElementChild.className = "fa-solid fa-check";
  22. } else {
  23. requirementItem.classList.remove("valid");
  24. requirementItem.firstElementChild.className = "fa-solid fa-circle";
  25. }
  26. });
  27. });
  28. eyeIcon.addEventListener("click", () => {
  29. // Toggle the password input type between "password" and "text"
  30. passwordInput.type = passwordInput.type === "password" ? "text" : "password";
  31. // Update the eye icon class based on the password input type
  32. eyeIcon.className = `fa-solid fa-eye${passwordInput.type === "password" ? "" : "-slash"}`;
  33. });
const passwordInput = document.querySelector(".pass-field input");
const eyeIcon = document.querySelector(".pass-field i");
const requirementList = document.querySelectorAll(".requirement-list li");

// An array of password requirements with corresponding 
// regular expressions and index of the requirement list item
const requirements = [
    { regex: /.{8,}/, index: 0 }, // Minimum of 8 characters
    { regex: /[0-9]/, index: 1 }, // At least one number
    { regex: /[a-z]/, index: 2 }, // At least one lowercase letter
    { regex: /[^A-Za-z0-9]/, index: 3 }, // At least one special character
    { regex: /[A-Z]/, index: 4 }, // At least one uppercase letter
]

passwordInput.addEventListener("keyup", (e) => {
    requirements.forEach(item => {
        // Check if the password matches the requirement regex
        const isValid = item.regex.test(e.target.value);
        const requirementItem = requirementList[item.index];

        // Updating class and icon of requirement item if requirement matched or not
        if (isValid) {
            requirementItem.classList.add("valid");
            requirementItem.firstElementChild.className = "fa-solid fa-check";
        } else {
            requirementItem.classList.remove("valid");
            requirementItem.firstElementChild.className = "fa-solid fa-circle";
        }
    });
});

eyeIcon.addEventListener("click", () => {
    // Toggle the password input type between "password" and "text"
    passwordInput.type = passwordInput.type === "password" ? "text" : "password";

    // Update the eye icon class based on the password input type
    eyeIcon.className = `fa-solid fa-eye${passwordInput.type === "password" ? "" : "-slash"}`;
});

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

jquery简单的验证码生成器插件

一款简单的基于jquery验证码插件,可自定义设置验证码字符长度,浏览器支持IE9,支持区分大小写及数字字母混合。
  表单验证
 1196  0

html5用户填写表单验证

主要使用了html表单required必填标签进行判断,无js脚本代码!
  表单验证
 6486  0

jquery会员注册表单验证

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

jquery轻量级表单验证插件

inputfollow.js是一个超级小的表单验证器,支持必填字段、Email邮箱和and/OR/IF逻辑操作验证。
  表单验证
 7374  0

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

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论