2022-08-18 09:12:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '#saveBtn', function (){
|
|
|
|
|
if(valueCheck("userInfoInsert")){
|
|
|
|
|
if(confirm("저장하시겠습니까?")){
|
|
|
|
|
contentFade("in");
|
|
|
|
|
const formData = new FormData($("#userInfoInsert")[0]);
|
|
|
|
|
$.ajax({
|
|
|
|
|
type : 'POST',
|
|
|
|
|
data : formData,
|
2022-08-19 02:04:38 +00:00
|
|
|
url : "/user/insertUserInfo",
|
2022-08-18 09:12:57 +00:00
|
|
|
processData: false,
|
|
|
|
|
contentType: false,
|
|
|
|
|
success : function(result) {
|
|
|
|
|
if(result === "userIdDuplication"){
|
|
|
|
|
alert("등록된 아이디입니다.")
|
|
|
|
|
}else{
|
2022-08-19 09:04:45 +00:00
|
|
|
alert("저장되었습니다.\n담당자 승인 후 로그인 가능합니다.")
|
2022-08-18 09:12:57 +00:00
|
|
|
$("#closeModalBtn").click();
|
|
|
|
|
$("#searchBtn").click();
|
|
|
|
|
}
|
|
|
|
|
contentFade("out");
|
|
|
|
|
},
|
|
|
|
|
error : function(xhr, status) {
|
|
|
|
|
alert("저장에 실패하였습니다.")
|
|
|
|
|
contentFade("out");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function valueCheck(form){
|
|
|
|
|
const targetForm = $("#"+form);
|
|
|
|
|
const userId = targetForm.find("#userId").val();
|
|
|
|
|
const password = targetForm.find("#modalPassword");
|
|
|
|
|
const passwordConfirm = targetForm.find("#passwordConfirm");
|
2022-08-25 09:39:21 +00:00
|
|
|
const userNm = targetForm.find("#userNm").val()
|
2022-08-18 09:12:57 +00:00
|
|
|
let returnFlag = true;
|
|
|
|
|
|
|
|
|
|
if(!userId){
|
|
|
|
|
alert("아이디를 입력해주세요.");
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}else{
|
|
|
|
|
const idReg = /^[a-z]+[a-z0-9]{5,19}$/g;
|
|
|
|
|
if(!idReg.test(userId)){
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
alert("아이디 조건이 맞지 않습니다.")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!password[0].disabled && !password.val()){
|
|
|
|
|
alert("비밀번호를 입력해주세요.");
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}
|
|
|
|
|
if(!password[0].disabled && !passwordConfirm.val()){
|
|
|
|
|
alert("비밀번호 확인을 입력해주세요.");
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}
|
2022-08-25 09:39:21 +00:00
|
|
|
if(!userNm){
|
2022-08-18 09:12:57 +00:00
|
|
|
alert("이름 입력해주세요.");
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}
|
|
|
|
|
if(returnFlag){
|
|
|
|
|
const passwordReg = /^(?=.*[a-zA-z])(?=.*[0-9])(?=.*[$`~!@$!%*#^?&\\(\\)\-_=+]).{8,16}$/;
|
|
|
|
|
if(!password[0].disabled){
|
|
|
|
|
if(!passwordReg.test(password.val())){
|
|
|
|
|
alert("비밀번호 조건이 맞지 않습니다.")
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}else{
|
|
|
|
|
if(password.val() !== passwordConfirm.val()){
|
|
|
|
|
alert("비밀번호가 같지 않습니다.");
|
|
|
|
|
returnFlag = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return returnFlag;
|
|
|
|
|
}
|