当前位置:网站首页>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;
})
})
边栏推荐
- Scala110-combineByKey
- [Android] recyclerview caching mechanism, is it really difficult to understand? What level of cache is it?
- sql to linq 之存储过程偏
- Log4j2 basic configuration
- Vs2010添加wap移动窗体模板
- LeetCode_ Factorization_ Simple_ 263. Ugly number
- 用OpenPose进行单个或多个人体姿态估计
- Scala111-map、flatten、flatMap
- LeetCode_ String_ Medium_ 151. Reverse the words in the string
- Splice a field of the list set into a single string
猜你喜欢

《三子棋》C语言数组应用 --n皇后问题雏形

反射-笔记

Application of object detection based on OpenCV and yolov3

Docker上运行redis以配置文件方式启动,连接客户端报错Error: Server closed the connection

Client error: invalid param endpoint is blank

Unable to start web server when Nacos starts

Deployment and simple use of PostgreSQL learning

Introduction to raspberry Pie: initial settings of raspberry pie

Single or multiple human posture estimation using openpose

Implement a simple restful API server
随机推荐
PHP implements non blocking (concurrent) request mode through native curl
Nacos2.1.0 cluster construction
剑指Offer | 二进制中1的个数
Browser workflow (Simplified)
LeetCode_因式分解_简单_263.丑数
期货在线开户是否安全?去哪家公司手续费最低?
43 box model
[Android] recyclerview caching mechanism, is it really difficult to understand? What level of cache is it?
@Scheduled source code analysis
Raft of distributed consistency protocol
npm的nexus私服 E401 E500错误处理记录
"Ask every day" what is volatile
【微信小程序】小程序宿主环境详解
[Nacos] what does nacosclient do during service registration
System. Accessviolationexception: an attempt was made to read or write to protected memory. This usually indicates that other memory is corrupted
What is the Internet of things
[C题目]力扣88. 合并两个有序数组
ice 100G 网卡分片报文 hash 问题
给VS2010自动设置模板,加头注释
When using jetty to run items, an error is reported: form too large or form too many keys