密码超过5个字符,至少有一个数字,一个字符 [英] Password with more than 5 character at least one number, one character

查看:231
本文介绍了密码超过5个字符,至少有一个数字,一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用javascript来验证密码,但是它没有达到要求。我需要超过5个字符的密码至少有一个号码,一个字符





我尝试过:



var pwd = /(?=.*\d)(?=.*[az]).{6,}/;

var pwd = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+){6,}$/



均未通过测试King382413

解决方案

/



都在测试中失败King382413


不要尝试使用单个正则表达式 - 这一点都不简单。

而不是,在javascript中执行一些检查:如何使用JavaScript构建密码验证器 - Matt Litzinger [ ^ ]

那样,当你的密码要求发生变化时(正如他们应该的那样,你应该允许 - 如果不是坚持 - 特殊字符也是如此),那就更简单了改变它们!


试试这个,



 ^(?=。*?[0- 9])(?=。* [!@#

I am using javascript to validate password but it's fails the requirement. I need Password with More than 5 Character at least one number, one character



What I have tried:

var pwd = /(?=.*\d)(?=.*[a-z]).{6,}/;
var pwd = /^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+){6,}$/

both fail on test "King382413"

解决方案

/

both fail on test "King382413"


Don't try to use a single Regex - it's not at all simple.
Instead, do it in javascript as a number of checks: How to Build a Password Validator with JavaScript – Matt Litzinger[^]
That way, when your password requirements change (as they should, you should allow - if not insist on - special characters as well) it's a heck of a lot simpler to change them!


Try this,

^(?=.*?[0-9])(?=.*[!@#


这篇关于密码超过5个字符,至少有一个数字,一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆