JS utilizes regular expressions to achieve simple password strength and weak judgment instance

Implementation:

1, the input character should be between 6-16; if less than 6 characters or greater than 16 characters, it will be prompted, and the strength is not displayed; 0 At 0, it is also given;

2, when the password is between 6-16 characters, if the password is all numbers or all letters, the weak; the password is a combination of numbers and letters, then display Strong; if the alphanumeric is applied, it is strong;

The effect is as follows:

JS利用正则表达式实现简单的密码强弱判断实例

JS利用正则表达式实现简单的密码强弱判断实例

JS利用正则表达式实现简单的密码强弱判断实例

JS利用正则表达式实现简单的密码强弱判断实例

The code is as follows: JS利用正则表达式实现简单的密码强弱判断实例

JS利用正则表达式实现简单的密码强弱判断实例

.mm-body {position: Relative; Height: 100px; Width: 450px Background-color: wheat;} .mm-top {height: 35px; width: 450px; Background-color: wheat;} .mm-sr {height: 30px; width: 100px; float: Left; Text-Align: Center Line-height: 30px;} # mm-pwd {float: Left; Height: 25px; Background-Color: ghostwhite; border-radius: 5px; width: 150px;} .mm-btm {height: 40PX; width: 140px; position: relative; margin-left: 110px;} # lv1, # lv2, # lv3 {height: 30px; width: 40px; border-top: 4px solid gainsboro; margin-left: 3px; float: Left; font-size: 18px; Text-align: center; line-height: 25px;}
  Please enter a password:          Heavy 
weak ->
function show () {var A = Document.GtelementByid ("MM-PWD"). Value; if (a.length == 0) {document.getlementByid ("MM-PD"). Innerhtml = "The password cannot be empty!";} else if (a.length
= 6 && A.Length
16) {document.getlementByid ("MM-PD"). Innerhtml = "The password is greater than 16 characters!"; Document.GetElementByid (. "Lv1") style.borderTopColor = "gainsboro";. Document.getElementById ( "lv2") style.borderTopColor = "gainsboro"; document.getElementById ( "lv3") style.borderTopColor = "gainsboro";.}}
<!--强度判断也可用表格做 Summary
The above is the full content of this article, I hope this paper is to learn or work on everyone. Can bring a certain help, if you have any questions, you can leave a message, thank you for your support of Tumi Cloud.
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment