我尝试实现简单的密码验证,但以下功能似乎不起作用,它们甚至没有显示在控制台中。我是否缺少一些非常简单的东西?"user strict";window.onload = init;function init() { document.getElementById("newPassword").onkeydown = checkPassword; document.getElementById("confirmPassword").onkeydown = checkConfirm;}function checkPassword(event){ let newPass = document.getElementById("newPassword").value; var passwordRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*&])[A-Za-z\d]@$!%*?&]{8,}$") if(!passwordRegex.test(newPass)){ feedback.innerHTML = "'"+newPass + "' is not secure." let result = passwordRegex.test(newpass); console.log("result: " + result); return false; } return true;}function checkConfirm(event) { let confirmPass = document.getElementById("confirmPassword").value; let newPass = document.getElement("newPassword").value; if(newPass != confirmPassword)) { feedback.innerHTML = "Password does not match."; return false; } return true;}let feedback - document.getElementById("feedback");function newUserRequest() {}function checkUser() { let email = document.getElementById(emailUser).value; let password = document.getElementById("passwordUser").value;}<div class="itemsFormDisplay"> <label class="detailNames">Password</label><br> <input id="newPassword" class="detailsFields" type="password" name="password" required></div><div class="itemsFormDisplay"> <label class="detailNames">ConfirmPassword</label><br> <input id="confirmPassword" class="detailsFields" type="password" name="password" required></div>
添加回答
举报
0/150
提交
取消