◽ HTML & CSS & JS, jQuery

[jQuery - 기능 - (1) ] 아이디 중복 체크 - 형식

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function sendIdChk(){
        var id = document.getElementById('id').value;
        if(id==null || id==""){
            alert('아이디를 입력해 주세요.');
            $('#id').focus();
            return;
        }else{
            requestAjax("test.do?id="+id);
        }
    }
    
    
    function requestAjax(url){
        var idchkf = document.getElementById("idchk");
        jQuery.ajax({
            type :'post'
            , url:url
            , dataType:"text"
            , cache : false 
            , success:function(res){
                if(res=='OK'){
                    $('#idchk').val("true");
                    alert('사용할 수 있는 아이디 입니다.');
                    $('#pwd').focus();
                }else if(res=='EXIST'){
                    $('#idchk').val("false");
                    alert('아이디가 이미 존재합니다.');
                }else{
                    $('#idchk').val("false");
                    alert('아이디 중복확인 실패하였습니다.');
                }
            }
               , error:function(xhr,textStatus){
                   $('#idchk').val("false");
                    alert("서버 전송중 오류가 발생하였습니다.\n\n잠시후 다시 시도해 주세요.");
            }
        });
    }
 

푸터바