当前位置:网站首页>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;
})
})
边栏推荐
- Scala111-map、flatten、flatMap
- @Scheduled source code analysis
- 瀑布流布局
- PHP implements non blocking (concurrent) request mode through native curl
- [C topic] Li Kou 206. reverse the linked list
- "Ask every day" what is volatile
- 海缆探测仪TSS350(一)
- 基于OpenCV和YOLOv3的目标检测实例应用
- Spark-SQL UDF函数
- [Android] recyclerview caching mechanism, is it really difficult to understand? What level of cache is it?
猜你喜欢

outline和box-shadow实现外轮廓圆角高光效果

如何解决Visual Studio中scanf编译报错的问题

Pl/sql creates and executes ORALCE stored procedures and returns the result set

String type time comparison method with error string.compareto

延迟加载源码剖析:

【JS高级】js之正则相关函数以及正则对象_02

Bridge NF call ip6tables is an unknown key exception handling

Vs2010添加wap移动窗体模板

"Ask every day" how locksupport realizes thread waiting and wakeup

Leetcode combination sum + pruning
随机推荐
Hbck 修复问题
MySQL之事务与MVCC
Meanshift clustering-01 principle analysis
Splice a field of the list set into a single string
记一次Spark foreachPartition导致OOM
The implementation process of inheritance and the difference between Es5 and ES6 implementation
Process control (Part 1)
Implementation of redis distributed lock
《三子棋》C语言数组应用 --n皇后问题雏形
Object.prototype.hasOwnProperty() 和 in
海缆探测仪TSS350(一)
Application of object detection based on OpenCV and yolov3
继承的实现过程及ES5和ES6实现的区别
密码强度验证示例
[C topic] Li Kou 88. merge two ordered arrays
简易轮播图和打地鼠
npm的nexus私服 E401 E500错误处理记录
"Ask every day" briefly talk about JMM / talk about your understanding of JMM
When using jetty to run items, an error is reported: form too large or form too many keys
outline和box-shadow实现外轮廓圆角高光效果