웹마스터 팁

관련글 : http://ulovem.com/board/zboard.php?id=StartPage_Info&no=28
<html>
<!--
        만든사람 : 윌
        홈페이지 : http://ulovem.com/startpage
-->
<Script Language="JavaScript">
function fnSubmit(stJob)
{
        var rtn;
        var frm = document.q;
        rtn = CheckObjValue( frm.TM_MemID,"ALPHANUM", 4, 12, "");        
        if ( CheckObjResult( frm.TM_MemID, 4, 12, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_Pwd,"ALPHANUM", 4, 9, "");        
        if ( CheckObjResult( frm.TM_Pwd , 4, 9, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_Name,"HAN", 2, 4, "");        
        if ( CheckObjResult( frm.TM_Name , 2, 4, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_Email,"Email", 5, 50, "Email");        
        if ( CheckObjResult( frm.TM_Email , 5, 50, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_JuminNo1,"NUM", frm.TM_JuminNo1, frm.TM_JuminNo2, "Jumin");        
        if ( CheckObjResult( frm.TM_JuminNo1 , frm.TM_JuminNo1, frm.TM_JuminNo2 , rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_Tel1,"NUM", 02, 100, "");        
        if ( CheckObjResult( frm.TM_Tel2 , 8, 9, rtn ) != true ) return

        rtn = CheckObjValue( frm.TM_Tel2,"NUMDASH", 8, 9, "");        
        if ( CheckObjResult( frm.TM_Tel2 , 8, 9, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_HP1,"NUM", 010, 019, "");        
        if ( CheckObjResult( frm.TM_HP1 , 8, 9, rtn ) != true ) return

        rtn = CheckObjValue( frm.TM_HP2,"NUMDASH", 8, 9, "");        
        if ( CheckObjResult( frm.TM_HP1 , 8, 9, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_ZipCode,"NUMDASH", 7, 7, "");        
        if ( CheckObjResult( frm.TM_ZipCode , 7, 7, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_ADDR1,"HANNUMALPHADASH", 10, 50, "");        
        if ( CheckObjResult( frm.TM_ADDR1 , 10, 50, rtn ) != true ) return;

        rtn = CheckObjValue( frm.TM_ADDR2,"HANNUMALPHADASH", 2, 50, "");        
        if ( CheckObjResult( frm.TM_ADDR2 , 2, 50, rtn ) != true ) return;

        frm.action = "./subscriber.asp";
        frm.submit();
        return;

}
function CheckObjResult( Obj, ObjSizeMin, ObjSizeMax, Rtn )
{
        
        if ( Rtn == true) return true;
        
        switch ( Rtn )
        {
                case 10:
                        alert("ObjType 불일치...");
                        break;
                case 11:
                        alert(Obj.id+"는(은) 숫자형만 가능 합니다.");
                        break;
                case 12:
                        alert(Obj.id+"는(은) 영문자형만 가능 합니다.");
                        break;
                case 13:
                        alert(Obj.id+"는(은) 영문자과 숫자만 사용가능 합니다.");
                        break;                        
                case 14:
                        alert(Obj.id+"는(은) 한글만 사용가능 합니다.");
                        break;                        
                case 15:
                        alert(Obj.id+"는(은) 숫자와 '-' 문자만 사용가능 합니다.");
                        break;                        
                case 16:
                        alert(Obj.id+"는(은) 한글,영문,숫자와 '-' 문자만 사용가능 합니다.");
                        break;                        
                case 20:
                        alert("ObjType 불일치(" + Obj.id + ")...");
                        break;
                case 21:
                        alert(Obj.id+"는(은) 입력 가능한 숫자 범위가 아닙니다..n " + ObjSizeMin +" 부터 " + ObjSizeMax + "사이의 숫자로 입력해주십시요" );
                        break;
                case 22:
                        alert(Obj.id+"는(은) 길이가 틀립니다...n " + ObjSizeMin +" 부터 " + ObjSizeMax + "사이의 길이로 입력해주십시요" );
                        break;
                case 31:
                        alert("주민번호 형식이 틀립니다. 다시 입력해 주십시요." );
                        ObjSizeMin.value = "";
                        ObjSizeMax.value = "";
                        ObjSizeMin.focus();
                        return Rtn;
                        break;
                case 32:
                        alert("Email 형식이 틀립니다. 다시 입력해주십시요." );
                        break;
                case 33:
                        alert("우편번호 검색이  제대로 되지 않았습니다.n다시 검색해주십시요");
                        break;
                case 9999:
                        alert("관리자에게 문의하십시요.");
                        return Rtn;
                        break;
                default:
                        alert("관리자에게 문의하십시요.");
                        return Rtn;
                        break;
        }

        Obj.value = "";
        Obj.focus();
        return Rtn;


}
// Obj        : Check 할 이름
// ObjType    : 각 항목의 필드의 성격 : NUM, ALPHA, ALPHANUM,HAN, NUMDASH, HANNUMALPHADASH
// ObjSizeMin : 항목의 최소길이
// ObjSizeMax : 항목의 최대 길이
// SpOption   : 옵션 : Jumin, Email
// 주의 주민 번호일경우
//        rtn = CheckObjValue( frm.TM_JuminNo1,"NUM", frm.TM_JuminNo1, frm.TM_JuminNo2, "Jumin");        
//        if ( CheckObjResult( frm.TM_JuminNo1 , frm.TM_JuminNo1, frm.TM_JuminNo2 , rtn ) != true ) return;
//  위처럼 ObjSizeMin에 주민번호 앞자리 ObjSizeMax에 주민번호 뒷자리를 넣어준다.
// 이함수를 실행 후 CheckObjResult 함수를 실행 시켜주면 alert 메세지와 함께 자동으로 빈자리에 Focus가 이루어 진다.
function CheckObjValue(Obj,ObjType, ObjSizeMin, ObjSizeMax, SpOption)
{

        if ( SpOption == "Jumin" ) {

                if ( isNumStr(ObjSizeMin.value) == false || isNumStr(ObjSizeMax.value) == false )
                        return 31;
                if ( ObjSizeMin.value.length != 6 || ObjSizeMax.value.length != 7 )
                        return 31;
                if ( isJumin( ObjSizeMin.value , ObjSizeMax.value ) == false )
                        return 31;
                return true;
                
        } else if ( SpOption == "Email" ) {
                if ( !(Obj.value.length >= ObjSizeMin && Obj.value.length <= ObjSizeMax) ){
                        return 22;
                }
                if ( isEmail(Obj.value) == false ) {
                        return 32;
                }
                return true;
        }

        if ( ObjType == "NUM" ) {
                if ( isNumStr( Obj.value, false ) == false ) {
                        return 11;
                }
        } else if (ObjType == "ALPHA" ) {
                if ( isAlphaStr( Obj.value, false ) == false ) {
                        return 12;
                }
        } else if (ObjType == "ALPHANUM" ) {
                if ( isAlphaNumStr( Obj.value , false) == false ) {
                        return 13;
                }
        } else if ( ObjType == "HAN" ) {
                if ( isHanStr(Obj.value,false) == false ) {
                        return 14;
                }
        } else if (ObjType == "NUMDASH" ) {
                if ( isNumDashString( Obj.value, false ) == false ) {
                        return 15;
                }
        } else if (ObjType == "HANNUMALPHADASH" ) {
                if ( isHanNumAlphaDash( Obj.value, true ) == false ) {
                        return 16;
                }
        } else {
                return 10;
        }
        
        if ( ObjType == "NUM" ) {
                if ( isNumSize ( Obj.value, ObjSizeMin, ObjSizeMax ) == false ) {
                        return 21;
                }
        } else {
                if ( !(Obj.value.length >= ObjSizeMin && Obj.value.length <= ObjSizeMax) ){
                        return 22;
                }
        }
        
        return true;
}
function isSpChr(ch)
{
        if ( ch == " " )
                return true
        else
                return false

}
function isHanNumAlphaDash(stValue, Spok)
{
  for(var i=0; i<stValue.length;i ++) {
    if ( isAlphaChr( stValue.charAt(i) ) == true ) continue;
    if ( isNumChr( stValue.charAt(i) ) == true ) continue;
    if ( stValue.charAt(i)  == "-" ) continue;
    if ( isHanChr( stValue.charCodeAt(i) ) == true ) continue;
    if ( Spok == true )
    {
            if ( isSpChr(stValue.charAt(i)) == true ) {
                    continue;
            }
    }
        return false;
  }
  return true;
}
function isAlphaNumStr(stValue, Spok)
{
  for(var i=0; i<stValue.length;i ++) {
    if ( isAlphaChr( stValue.charAt(i) ) == true ) continue;
    if ( isNumChr( stValue.charAt(i) ) == true ) continue;
    if ( Spok == true )
    {
            if ( isSpChr(stValue.charAt(i)) == true ) {
                    continue;
            }
    }
    alert( stValue.charAt(i) );
        return false;
  }
  return true;
        
}
function isHanStr(stValue)
{
  for(i=0;i<stValue.length;i++) {
          if (isHanChr( stValue.charCodeAt(i) ) == true) continue;
  }

}
function isHanChr(ch)
{
        if ( ch > 128 ) return true;
        else return false;
}
function isNumDashString(stValue, Spok)
{
  for(var i=0 ; i< stValue.length ; i ++) {
    if ( isNumDashChr(stValue.charAt(i)) == true ) continue;

    if ( Spok == true )
    {
            if ( isSpChr(stValue.charAt(i)) == true ) {continue;} else {return false;}
    }
    
        return false;                
  }

  return true;
}
function isNumDashChr(ch)
{
        
        if ( isNumChr(ch) == true || ch == "-" ) {
                return true
        } else {
                return false
        }
}
function isNumSize(num, x, y )
{
        if ( num >= x && num <= y ) {
                return true;
        } else {
                return false;
        }
        
}
function isAlphaStr(stValue, Spok)
{
  for(var i=0; i<stValue.length;i ++) {
    if ( isAlphaChr( stValue.charAt(i) ) == true ) continue;
    if ( Spok == true )
    {
            if ( isSpChr(stValue.charAt(i)) == true ) {
                    continue;
            }
    }
            
        return false;
  }
  return true;
}

function isAlphaChr(ch)
{
        if ( isUpperAlphaChr(ch) == true || isLowerAlphaChr(ch) == true )
                return true
        else
                return false
}

function isUpperAlphaChr(ch)
{
        if ( ch >= 'A' && ch <= 'Z' )
                return true
        else
                return false
}

function isLowerAlphaChr(ch)
{
        if ( ch >= 'a' && ch <= 'z' )
                return true
        else
                return false
}
function isEmail(str)
{
        var filter=/^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i
        if (filter.test(str)) { return true; }
        else { return false; }
}

function isJumin(str_jumin1,str_jumin2)
{
        return ChkJumin(str_jumin1,str_jumin2)
}
function ChkJumin(str_jumin1,str_jumin2) {
    errfound = false;
    var str_jumin1;
    var str_jumin2;
    var checkImg='';

    var i3=0
    for (var i=0;i<str_jumin1.length;i++) {
        var ch1 = str_jumin1.substring(i,i+1);
        if (ch1<'0' || ch1>'9') { i3=i3+1 }
    }
    if ((str_jumin1 == '') || ( i3 != 0 )) {
        return false;
    }

    var i4=0
    for (var i=0;i<str_jumin2.length;i++) {
        var ch1 = str_jumin2.substring(i,i+1);
        if (ch1<'0' || ch1>'9') { i4=i4+1 }
    }
    if ((str_jumin2 == '') || ( i4 != 0 )) {
      return false;
    }
//                연도 제한 없음
//    if(str_jumin1.substring(0,1) < 4) {
//        return false;
//    }

    if(str_jumin2.substring(0,1) > 2) {
        return false;
    }

    if((str_jumin1.length > 7) || (str_jumin2.length > 8)) {
        return false;
    }

    if ((str_jumin1 == '72') || ( str_jumin2 == '18')) {
      return false;
    }
    
    var f1=str_jumin1.substring(0,1)
    var f2=str_jumin1.substring(1,2)
    var f3=str_jumin1.substring(2,3)
    var f4=str_jumin1.substring(3,4)
    var f5=str_jumin1.substring(4,5)
    var f6=str_jumin1.substring(5,6)
    var hap=f1*2+f2*3+f3*4+f4*5+f5*6+f6*7
    var l1=str_jumin2.substring(0,1)
    var l2=str_jumin2.substring(1,2)
    var l3=str_jumin2.substring(2,3)
    var l4=str_jumin2.substring(3,4)
    var l5=str_jumin2.substring(4,5)
    var l6=str_jumin2.substring(5,6)
    var l7=str_jumin2.substring(6,7)
    hap=hap+l1*8+l2*9+l3*2+l4*3+l5*4+l6*5
    hap=hap%11
    hap=11-hap
    hap=hap%10
    if (hap != l7) {
      return false;
    }    
      
    var i9=0

    if (!errfound)
        return true;
}

function isNumStr(stValue)
{
  for(var i=0 ; i< stValue.length ; i ++) {
    if ( isNumChr(stValue.charAt(i)) == true ) continue;
    if ( Spok == true )
    {
            if ( isSpChr(stValue.charAt(i)) == true ) {
                    continue;
            }
    }
        return false                
  }
  return true
}
function isNumChr(ch)
{
        if ( ch >= '0'+ ' && ch <= '9' ) {
                return true;
        } else {
                return false;
        }
}

function fnSizeCheck(obj,nextobj)
{
        if (obj.value.length == obj.maxLength ) {
                nextobj.focus();
        }

}
</Script>
<body>
<!--
        HTML 구성시 유의점
                각 항목의 id와 maxLength를 반드시 명기 해준다.
                maxLength는 자동 포커스를 위해 사용되며 (fnSizeCheck 참조)
                id는 alert메세지를 뿌려주기 위해 사용된다 된다.(CheckObjResult 참조)
-->

<form name=q method=post action="">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr><td colspan=4 align=center ><b>회원 가입</b></td></tr>
          <col Width=80 ></col>
          <col Width=120></col>
          <col Width=80></col>
          <col Width=400></col>
    <tr>
      <td>ID</td>
      <td><input type="text" name="TM_MemID" id="아이디" value="" Size=14 maxlength=12         onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_Pwd);"><br>
      <td>비밀번호</td>
      <td><input type="text" name="TM_Pwd" id="비밀번호" value="" Size=14 maxlength=10         onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_Name);">
      </td>
    </tr>
    <tr>
      <td>이름</td>
      <td><input type="text" name="TM_Name" id="이름" value="" Size=10 maxlength=4 onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_Email);" ></td>
      <td>Email</td>
      <td><input type="text" name="TM_Email" id="Email" value="" Size=30 maxlength=50 onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_JuminNo1);"></td>
    </tr>
    <tr>
      <td>주민등록번호</td>
      <td colspan="3"><input type="text" name="TM_JuminNo1" id="주민번호 앞자리" value=""
                                              Size=8 maxlength=6
                                              onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_JuminNo2);"> - <input
                                              type="text" name="TM_JuminNo2" id="주민번호 뒷지리"
                                              value=""  Size=10 maxlength=7
                                              onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_Tel1);">
      </td>
    </tr>
    <tr>
      <td>전화번호</td>
      <td><input type="text" name="TM_Tel1" id="전화 지역번호" value=""  Size=4 maxlength=3 onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_Tel2);"> <input type="text" id="전화번호뒷자리" name="TM_Tel2" value="<%=TM_Tel2%>"  Size=10 maxlength=9 onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_HP1);"></td>
      <td>휴대폰</td>
      <td><input type="text" name="TM_HP1" id="휴대폰 앞자리" value=""  Size=4 maxlength=3 onKeyUp="JavaScript:fnSizeCheck(this, mf_member.TM_HP2);"> <input type="text" id="휴대폰뒷자리" name="TM_HP2" value="<%=TM_HP2%>"  Size=10 maxlength=9 ></td>
    </tr>
    <tr>
      <td>주소</td>
      <td colspan="3"><input type="text" name="TM_ZipCode" id="우편번호"  value="" Size=7 >
        기본 주소 <input type="text" id="기본주소" name="TM_ADDR1" value="" Size=60 maxlength=50 ><br>
        상세 주소 <input type="text" id="상세주소" name="TM_ADDR2" value=""  Size=60 maxlength=50 ></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td colspan="4" center><div align="center">
                      <a href="JavaScript:fnSubmit();">가입</a>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      <td> </td>
    </tr>
  </table>
</form>
</body>
</html>

제목 글쓴이 날짜
허접한 풀다운 메뉴 소스입니다. (유용한 팁 일지는 모르겠네요.) [9] file tintintm 2004.03.23
버튼 만들기 [1] 旻天 2004.03.23
MS agent online object - Default Character 인 Merlin Action 추가 [2] 꽃ちゃん 2004.03.19
움직이는 타이틀바 [4] 김동현 2004.03.18
웹브라우저 상태바가 밑으로 내려오는 소스 [5] 프리서버 2004.03.16
브라우져(윈도우) 창의 크기(사이즈)를 조절하는 소스입니다 [5] 나야 2004.03.15
프레임사이트에서 자식 프레임(URL)로 직접 치고 들어 올경우 다시 프레임 부모로 돌려보내는 소스 나야 2004.03.15
전체 include menu 만들기(롤오버 이미지 사용) [4] Neoyoung 2004.03.14
[초간단 자바스크립트!] 서브메뉴 만들기...~ [11] ∑Ztxy 2004.03.10
뉴스티커 [16] file zero 2004.03.10
보안문서 만들기 [5] 민우주 2004.03.07
팝업 창 띄우고 어미창 사라지게 하는 소스 [5] piasol 2004.03.06
방문자 OS보여주기 [5] 구조반 2004.03.05
벅스뮤직 음악듣기 및 시작 정지 버튼 넣기(기타 음악파일도...) [3] 카멜롯™ 2004.03.04
회원 가입 페이지 이젠 끝이다 [5] 2004.03.03
우뚜같은 포워딩 페이지에서 프레임 깨기.(프레임 없애기) [17] 김영성 2004.02.19
벅스뮤직 플레이어 스크립트 추출기 [4] 이녀석 2004.02.16
XML+JS 연동 다중셀렉트 투헤븐 2004.02.16
BGM Player (배경 음악) [17] 장진석 2004.02.16
페이지 내에 주소창 달기 [1] piasol 2004.02.09