Skip to content

Commit

Permalink
Fix/비밀번호 조건 해제
Browse files Browse the repository at this point in the history
  • Loading branch information
choiyoubin committed Mar 26, 2024
1 parent 798f092 commit cab2960
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const UserInputPassword = () => {
const handlePasswordChange = (e) => {
const newPassword = e.target.value;
setPassword(newPassword);
isPasswordCombinationValid(newPassword);
// isPasswordCombinationValid(newPassword);
};

const handlePasswordCheckChange = (e) => {
Expand All @@ -25,34 +25,36 @@ const UserInputPassword = () => {
validatePassword(password, newPasswordCheck);
};

const isPasswordLength = (password) => {
const minLength = 8;
return password.length >= minLength;
};
// const isPasswordLength = (password) => {
// const minLength = 8;
// return password.length >= minLength;
// };

const isPasswordCombinationValid = (password) => {
const hasLetter = /[a-zA-Z]/.test(password);
const hasNumber = /\d/.test(password);
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
return hasLetter && hasNumber && hasSpecialChar;
};
// const isPasswordCombinationValid = (password) => {
// const hasLetter = /[a-zA-Z]/.test(password);
// const hasNumber = /\d/.test(password);
// const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
// return hasLetter && hasNumber && hasSpecialChar;
// };

const validatePassword = (newPassword, newPasswordCheck) => {
if (newPassword !== newPasswordCheck) {
setPasswordError(true);
} else if (!isPasswordLength(newPassword)) {
setPasswordError(true);
} else if (!isPasswordCombinationValid(newPassword)) {
setPasswordError(true);
} else {
// } else if (!isPasswordLength(newPassword)) {
// setPasswordError(true);
// } else if (!isPasswordCombinationValid(newPassword)) {
// setPasswordError(true);
// } else {
setPasswordError(false);
}
};
return(
<div className="signup-page-content-password-wrapper">
<label className="signup-page-content-password-label-style">비밀번호</label>
<div className="signup-page-content-password-label-plus-text">
영문+숫자+특수문자 8자 이상
{/* 영문+숫자+특수문자 8자 이상 */}
비밀번호를 입력해주세요
</div>
<div>
<input
Expand All @@ -79,10 +81,10 @@ const UserInputPassword = () => {
<LoginChkAlrm icon={"X"} paddingSize={"0.45rem"}>
{password !== confirmPassword
? "비밀번호가 일치하지 않습니다."
: !isPasswordLength(password)
? "8자 이상 입력해야 합니다."
: !isPasswordCombinationValid(password)
? "영문+숫자+특수문자의 조합이어야 합니다."
// : !isPasswordLength(password)
// ? "8자 이상 입력해야 합니다."
// : !isPasswordCombinationValid(password)
// ? "영문+숫자+특수문자의 조합이어야 합니다."
: null}
</LoginChkAlrm>
) : <div style={{minHeight: "0.9rem"}}/>
Expand Down

0 comments on commit cab2960

Please sign in to comment.