아이디 중복체크 버튼을 만들었는데 기존회원과 아이디가 겹칠 경우 채택완료
굼떠
2년 전
조회 1,632
</p>
<p>$("#reg_mb_id").keyup(function(event){
if (!(event.keyCode >=37 && event.keyCode<=40)) {
var inputVal = $(this).val();
var check = /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/;
if(check.test(inputVal)){
$(this).val("");
alert('영문자, 숫자, _ 만 입력 가능. 최소 3자이상 입력하세요.');
}
}
});
$(".idcheck").click(function(){
var msg = reg_mb_id_check();
let checkID = document.getElementById("reg_mb_id");
var id = document.getElementById("reg_mb_id").value; // 사용자가 입력한 아이디 가져오기
if(checkID.value.length == 0) {
alert('아이디를 입력해주세요.');
} else if(checkID.value.length < 3) {
alert('아이디는 3글자 이상이어야 합니다.');
} else {
if(msg == "" || msg == null){
if (check_prohibited_words(id)) {
alert("사용할 수 없는 단어가 포함되어 있습니다.");
}
else if(!confirm("가입할 수 있는 아이디입니다.\n입력하신 아이디를 사용하시겠습니까?")){
document.getElementById("reg_mb_id").value = "";
}
}
else
{
alert(msg);
}
}
});
function check_prohibited_words(id) {
var prohibited_words = ["admin", "administrator", "webmaster","manager","guest"]; // 사용금지단어 리스트
for (var i = 0; i < prohibited_words.length; i++) {
if (id.includes(prohibited_words[i])) {
return true;
}
}
return false;
}</p>
<p>
버튼을 클릭했을 때 위와 같이 작성해서 한글입력 제한 및 사용 금지 단어 지정 등 기능을 추가하였습니다.
근데 문제는 기존에 있는 회원 아이디를 넣었을 경우 중복 버튼 클릭 시 가입할 수 있는 아이디라고 뜨는데 저 영역에서 기존 아이디를 검색하려면 어떻게 해야하나요?
가능하다고 해서 가입버튼을 누르면 그 순간에만 중복된 아이디라고 뜨네요.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인