【问题标题】:Creating a password创建密码
【发布时间】:2016-12-22 14:08:27
【问题描述】:

密码必须匹配且长度为 6-20 个字符,并且还必须包含: 至少一个字母字符 至少一个数字或特殊字符 不超过三个重复字符 请帮帮我

【问题讨论】:

  • 1) 伸手去拿键盘,2) 输入符合这些要求的密码。
  • 真的哈哈。这是经典
  • 大多数语言可以创建随机的字母/数字字符串。您需要使用哪种语言创建密码?

标签: passwords


【解决方案1】:

需要三项检查,在输入框中输入maxlength="20",也可以添加更多特殊字符

var password = getPassword;
if(password.length <= 6){
 // display error too short
}
else if((/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d_@./#&+-]*$/.test(password) == false){
 // display error must be 1 letter and 1 number or special character
}
else if(password.replace(/[^a-z]/gi, "").length>3){
  // display error cannot be 3 alphabet characters repeating 
}
else{
// success 
}

如果您需要更多重复功能,请查看此解决方案

regular expression with no more than 3 alphabets concurrently should not accept 1a1a1a1a1

【讨论】:

    猜你喜欢
    • 2017-08-25
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多