在密码强度检查器中使用一系列不可用的单词

发布于 2024-11-07 05:37:41 字数 454 浏览 3 评论 0原文

我是 jQuery 新手,目前正在修改 Firas Kassem 的密码强度计,并希望检查一系列不允许的单词。我遇到了 这个问题作为起点。我目前所拥有的是:

var badArr = ['password','system','user','demo','test','default'] //Array of unusable words
//check if bad words are in password
$.each(badArr, function(index,value)
{
    if(password.match(value))
        return badPass
})

问题是它不返回 badPass。对我做错了什么有任何见解吗?

I'm new to jQuery and am currently working on modifying Firas Kassem's password strength meter and wanted to check against an array of disallowed words. I came across this question for a starting point. What I have currently is:

var badArr = ['password','system','user','demo','test','default'] //Array of unusable words
//check if bad words are in password
$.each(badArr, function(index,value)
{
    if(password.match(value))
        return badPass
})

The problem is that it doesn't return the badPass. Any insight on what I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝眼睛不忧郁 2024-11-14 05:37:41

实际上,我已经建立了自己的力量计,因为我不需要力量计;只是一个需求检查器。

通过使用简单的password.match和正则表达式,我能够检查这些特定的单词。给我的要求没有指定大小写字母,所以我做了一个简单的匹配。

 password.match(/((SYSTEM)|(Password)|(Default)|(USER)|(Demo)|(TEST))/)

我还可以使用不同的算法检查以下内容。

 //password != user name, first name, or last name
 //password != 6 chars, 6 nums, or 6 symbols
 //password != social security numbers
 //password != a date
 //password = 3 of 4 requirements (upper, lower, num, char)

一个有用的网站是 www.regular-expressions.info

I've actually built my own since I don't have the need for a strength meter; just a requirements checker.

By using a simple password.match using a regular expression, I was able to check for these certain words. The requirements that were given to me didn't specify upper or lower case letters, so I did a simple match.

 password.match(/((SYSTEM)|(Password)|(Default)|(USER)|(Demo)|(TEST))/)

I was also able to check for the below using different algorithms.

 //password != user name, first name, or last name
 //password != 6 chars, 6 nums, or 6 symbols
 //password != social security numbers
 //password != a date
 //password = 3 of 4 requirements (upper, lower, num, char)

A helpful site was www.regular-expressions.info

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文