일단 빨리
function update_user() {
const name = $("#name").val();
const address = $("#address").val();
const phone_number = $("#phone_number").val();
const currentPassword = $("#currentPassword").val();
const newPassword = $("#newPassword").val();
const confirmedPassword = $("#confirmedPassword").val();
if (!name || !address || !phone_number || !currentPassword || !newPassword || !confirmedPassword) {
alert("정보를 모두 입력해 주세요.");
} if (( currentPassword == newPassword) && newPassword){
alert('현재 비밀번호와 바꿀 비밀번호가 같습니다, 다르게 수정해주세요')
} if (newPassword !== confirmedPassword){
alert("새로운 비밀번호 확인이 틀렸습니다.");
} else {
$.ajax({
type: "put",
url: "http://localhost:4000/api/user",
data: {
name,
address,
phone_number,
currentPassword,
newPassword,
confirmedPassword
},
success: function (response) {
alert(`${name}님 회원정보가 수정되었습니다`);
location.href = "/";
},
error: function (error) {
console.log("에러이유:", error);
},
});
}
}'내배캠 TIL WIL > 내배캠 til' 카테고리의 다른 글
| 내배캠 til 61일차 nest.js 입문 시작 (0) | 2023.02.10 |
|---|---|
| 내배캠 til 60일차 플잭 후기 (0) | 2023.02.09 |
| 내배캠 til 58일차 내가 만?든 ejs (0) | 2023.02.07 |
| 내배캠 til 57일차 내가 만든 쿠키~를 사용한 회원정보 수정 (0) | 2023.02.06 |
| 내배캠 til 55일차 열심히 써도 구리다면 (0) | 2023.02.02 |