<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="a">aa</button>
    <script>
        let a = document.querySelector('#a')
        a.onclick = function(){
        //正则 密码设置规则:大写字母、小写字母、数字和特殊符号,这4类必须包括3类,长度8到16位。
  var regex = new RegExp('(?=.*[0-9])(?=.*[A-Za-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\\.]{8,16}$')
            console.log( regex.test('wdr@1234'))
        }
    </script>
</body>
</html>
Logo

前往低代码交流专区

更多推荐