자바 스크립트를 사용하여 비밀번호의 유효성을 검사하려고합니다. 비밀번호를 변경할 때 입력 한 새 비밀번호와 새 비밀번호를 다시 입력 한 비밀번호가 같아야합니다. 새로운 암호를 두 번 그래서 둘 다 일치해야하지만 동시에, 나는 새로운 암호가 적어도 6 문자 길이가 있는지 확인하려면, 내가 별도로 이러한 기능을 가지고 있지만 그들을 결합하는 방법을 알고 ... 감사합니다 사전에 도와주세요!비밀번호 확인
function validatePassword()
{
if (document.getElementById("new_password").value.length < "5")
{
<!--If pasword is less than 5 characters long, display error message-->
alert("Please ensure your password is at least 6 characters long.");
return false;
}
return true;
}
방법 :
function validatePassword()
{
var new_password = document.getElementById("new_password").value;
var confirm_new_password = document.getElementById("confirm_new_password").value;
<!-- if they match, go to next page -->
if (new_password == confirm_new_password)
{
return true;
}
<!-- if they don't match, an error message is displayed -->
else
{
alert("Passwords do not match.");
}
return false;
}
이 암호의 길이입니다 : 이것은 내가 지금까지 무엇을 가지고
는...
이 확인 새 암호가 일치하는 것입니다 나는 두 개의 새로운 암호를 검사하여 일치하도록 SINGLE 함수를 구성하고 두 문자가 6 문자보다 긴지 확인합니다.
참고로, 드롭 박스가 암호 검증 JS를 발표하고 지금까지 내가 본 것 중에 최고입니다 - https://tech.dropbox.com/2012/04/zxcvbn-realistic-password-strength- 견적/ –