121 lines
3.4 KiB
JavaScript
121 lines
3.4 KiB
JavaScript
$(document).on('click', '#dicCodeSearchBtn', function (){
|
|
const dicCode = $("#dicCode").val();
|
|
if(dicCode!==''){
|
|
$.ajax({
|
|
url: '/kwms/getEmpInfoToJoinForm',
|
|
data: {dic: dicCode},
|
|
type: 'GET',
|
|
dataType:"html",
|
|
success: function(html){
|
|
$("#userInsertModalContent").empty().append(html)
|
|
$(".dateSelector").datepicker({
|
|
format: "yyyy-mm-dd",
|
|
language: "ko",
|
|
autoclose: true
|
|
});
|
|
},
|
|
error:function(e){
|
|
|
|
}
|
|
});
|
|
}else{
|
|
alert("공무원식별번호를 입력해주세요.")
|
|
}
|
|
})
|
|
|
|
$(document).on('click', '#saveBtn', function (){
|
|
if(valueCheck()){
|
|
if(confirm("저장하시겠습니까?")){
|
|
contentFade("in");
|
|
const formData = new FormData($("#userInfoInsert")[0]);
|
|
$.ajax({
|
|
type : 'POST',
|
|
data : formData,
|
|
url : "/user/insertUserInfo",
|
|
processData: false,
|
|
contentType: false,
|
|
success : function(result) {
|
|
if(result === "userIdDuplication"){
|
|
alert("등록된 아이디입니다.")
|
|
}else{
|
|
alert("저장되었습니다.\n담당자 승인 후 로그인 가능합니다.")
|
|
$("#closeModalBtn").click();
|
|
$("#searchBtn").click();
|
|
}
|
|
contentFade("out");
|
|
},
|
|
error : function(xhr, status) {
|
|
alert("저장에 실패하였습니다.")
|
|
contentFade("out");
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
function valueCheck(){
|
|
const targetForm = $("#userInfoInsert");
|
|
const userId = targetForm.find("#userId").val();
|
|
const password = targetForm.find("#modalPassword");
|
|
const passwordConfirm = targetForm.find("#passwordConfirm");
|
|
const userNm = targetForm.find("#userNm").val();
|
|
const phoneNo = targetForm.find("#phoneNo").val();
|
|
const email = targetForm.find("#email").val();
|
|
const ogCd = targetForm.find("#ogCd").val();
|
|
const titleCd = targetForm.find("#titleCd").val();
|
|
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;
|
|
}
|
|
if(!userNm){
|
|
alert("이름을 입력해주세요.");
|
|
returnFlag = false;
|
|
}
|
|
if(!phoneNo){
|
|
alert("휴대전화를 입력해주세요.");
|
|
returnFlag = false;
|
|
}
|
|
if(!email){
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!ogCd){
|
|
alert("관서를 선택해주세요.");
|
|
returnFlag = false;
|
|
}
|
|
if(!titleCd){
|
|
alert("계급을 선택해주세요.");
|
|
returnFlag = false;
|
|
}
|
|
return returnFlag;
|
|
} |