当前位置:网站首页>Example of password strength verification
Example of password strength verification
2022-07-25 15:12:00 【Deep sea blue mountains】
Verify password strength , Example rule : With 6-18 Bit code , By digital 、 Case letters 、 More than two special characters , Determine the password strength according to the combination of passwords
Effect of the sample

html Code
<div class="row">
<div class="col-md-12 ">
<input type="password" id="password" class="form-control" name="password" placeholder=" password ">
<label class="mt-1 labeltip" for="">8-18 position , Include capital letters 、 Lowercase letters 、 Symbol 、 In numbers 2 More than species </label>
<label id="password-error" class="error col-md-12 passerrow mg-l" for="password"></label>
</div>
</div>js Code example :
$(function () {
// Password authentication 6-18 Bit code , By digital 、 Case letters 、 More than two special characters
jQuery.validator.addMethod("isPwd", function (value, element) {
value = jQuery.trim(value);
let reg=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9_A-Za-z\!\@\#\$\%\^\&\*\(\)\+\?\<\>\/\,\.]{8,18}$/;
return this.optional(element) || reg.test(value);
}, " Please lose 8-18 position , Include capital letters 、 Lowercase letters 、 Symbol 、 In numbers 2 More than species ");
let form = $('#form-register').validate({
rules: {
password: {
required: true,
isPwd: true
},
confirmPassword: {
required: true,
equalTo: "#password"
},
},
messages: {
password: {
required: ' Please enter 8-18 position , Contain letters 、 Symbol 、 In numbers 2 More than species '
},
confirmPassword: {
required: ' Please enter the confirmation password ',
equalTo: ' The password input is inconsistent , Please re-enter '
},
}
})
let reg = /.*[A-Z]+.*/ // Whether it contains capital letters
let reg2 = /.*[a-z]+.*/ // Whether it contains lowercase letters
let reg3 = /.*[0-9]+.*/ // Contains figures
let reg4=/.*[\!\@\#\$\%\^\&\*\(\)\+\?\<\>\/\,\.]+.*/ // Contains special characters
let pwdstrong = 0;
let pwdLevel = 0;
// Password strength verification
$('#password').on('keyup', function () {
let val = $.trim(this.value)
if (!val) {
$('.pwd-strength span').removeClass('strength-green')
// $('.strength-name').text('')
return
}
if (reg.test(val)) {
pwdstrong += 1;
}
if (reg2.test(val)) {
pwdstrong += 1;
}
if (reg3.test(val)) {
pwdstrong += 1;
}
if (reg4.test(val)) {
pwdstrong += 1;
}
$('.pwd-strength span').removeClass('strength-green').filter(':lt(' + pwdstrong + ')').addClass('strength-green');
// $('.strength-name').text(pwdstrong === 3 ? " strong " : pwdstrong === 2 ? " in " : " weak ");
pwdLevel = pwdstrong;
pwdstrong = 0;
})
})
边栏推荐
- Use the command to check the WiFi connection password under win10 system
- Solve the error caused by too large file when uploading file by asp.net
- 剑指Offer | 二进制中1的个数
- Unable to start web server when Nacos starts
- Copy files / folders through Robocopy
- 图片的懒加载
- SPI传输出现数据与时钟不匹配延后问题分析与解决
- System. Accessviolationexception: an attempt was made to read or write to protected memory. This usually indicates that other memory is corrupted
- 浏览器工作流程(简化)
- 推荐10个堪称神器的学习网站
猜你喜欢

ice 100G 网卡分片报文 hash 问题

Spark 内存管理机制 新版

ESXI6.7.0 升级到7.0U3f(2022年7月12 更新)

6月产品升级观察站

Use the command to check the WiFi connection password under win10 system

Leo-sam: tightly coupled laser inertial odometer with smoothing and mapping

System.AccessViolationException: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏

用OpenPose进行单个或多个人体姿态估计

如何解决Visual Stuido2019 30天体验期过后的登陆问题

Unable to start web server when Nacos starts
随机推荐
[C topic] the penultimate node in the Niuke linked list
期货在线开户是否安全?去哪家公司手续费最低?
TypeScript学习2——接口
"How to use" observer mode
LeetCode_ String_ Medium_ 151. Reverse the words in the string
Spark DF增加一列
ESXI6.7.0 升级到7.0U3f(2022年7月12 更新)
浏览器工作流程(简化)
图片裁剪cropper 示例
How much memory can a program use at most?
流程控制(上)
[C题目]牛客 链表中倒数第k个结点
继承的实现过程及ES5和ES6实现的区别
如何更新更新数据库中的json值?
"Ask every day" reentrantlock locks and unlocks
Vs2010添加wap移动窗体模板
Deployment and simple use of PostgreSQL learning
BigDecimal rounds the data
Raft of distributed consistency protocol
Add the jar package under lib directory to the project in idea