<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="addr/js/jquery.min.js"></script>
<style>
#msg {
width: 100px;
margin: 20px 0;
display: none;
border: 1px solid #ccc;
}
#progress {
width: 100%;
height: 5px;
background: red;
}
#pwd{
width: 240px;
}
</style>
</head>
<body>
<input id="pwd"></input>
<div id="msg">
<div id="progress"></div>
</div>
<script>
$('#pwd').on('input', function () {
let level = 0
let str = $(this).val()
if (/\d/.test(str)) level++
if (/[a-z]/.test(str)) level++
if (/[A-Z]/.test(str)) level++
if (str.length > 10) level++
if (/[\.\~\@\#\$\%\^\&\*]/.test(str)) level++
$('#msg').show()
let arr = ['red', 'orange', 'yellow', 'blue', 'green']
$('#progress').css('width', (leave / 5) * 100 + "%").css("background", arr[level - 1])
})
</script>
</body>
</html>