前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
<head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> var password=prompt("请设置您的密码"); // 判断密码的长度,如果不是6位,否则 if(password.length!=6){ alert("请输入6位的数字密码"); }else{ // 如果密码是非数字,否则是数字 if(isNaN(password)){ alert("密码必须要是数字"); }else{ alert("密码设置正确"); } } </script> </body> </html>