아이디 유효성 검사 ajax 안되는 이유가 무엇일까요..
본문
제일 아래에 두문단 아이디 중복체크, 패스워드 일치는 잘 작동합니다.
function registerCheckFunction() { ~~~
function passwordCheckFunction() {~~~
하지만 그 위의 친구들은 작동하지 않는데 무엇이 문제일까요?
db까지 갔다오는건 중복체크만 아닌가요??...
script type="text/javascript">
let usernameCheck = /[가-힣A-Za-z\d]{4,10}$/; // 최소4자, 최대 10자의 문자
let passwordCheck = /(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/; //최소 8 자, 최소 하나의 문자 및 하나의 숫자
let numberCheck = /[0-9]/; // 숫자인경우
let nameCheck = /[a-zA-Z가-힣]/; // 한글, 영어만
$('#username').blur(function(){
console.log($('#username'),val());
if($('#username').val().length < 4){
$('#helper1').text("4자 이상 입력해주세요.");
} if($('#username').val().length > 11) {
$('#helper1').text("10자 이하로 입력해주세요.");
}
});
$('#password').blur(function(){
console.log($('#password').val());
if(!passwordCheck.test($('#password').val())){
console.log("비밀번호가 유효하지 않습니다.");
$('#helper2').text("최소8자 이상, 하나의 문자 및 숫자를 입려해주세요");
}else{
console.log("비밀번호 사용가능");
$('#helper2').text("사용가능한 비밀번호입니다.");
}
});
$('#name').blur(function(){
console.log($('#name').val());
if(!nameCheck.test($('#name').val())){
$('#helper3').text("문자만 입력하세요.");
}else{
console.log("비밀번호 입력가능");
$('#helper3').text("--");
}
});
$('#phone').blur(function(){
console.log($('#phone').val());
if(!numberCheck.test($('#phone').val())){
$('#helper4').text("숫자만 입력 가능합니다.");
}else{
console.log("입력가능");
$('#helper4').text("입력가능합니다.");
}
});
function registerCheckFunction() {
var username = $('#username').val();
$.ajax({
type: 'POST',
url: './UserRegisterCheckServlet',
data: {username: username},
success: function(result) {
if(result == 1) {
$('#registerCheckMessage').html('*사용 가능한 아이디입니다.');
$('#registerCheckMessage').css('color','green');
}
else {
$('#registerCheckMessage').html('*이미 사용중인 아이디입니다.');
$('#registerCheckMessage').css('color','#d64643');
}
}
});
} ;
function passwordCheckFunction() {
var password1 = $('#password1').val();
var password2 = $('#password2').val();
if(password1 != password2) {
$('#passwordCheckMessage').html('*비밀번호가 일치하지 않습니다.');
} else{
$('#passwordCheckMessage').html('');
}
};
</script>