휴대폰번호 검사

· 17년 전 · 1603

<SCRIPT LANGUAGE="JavaScript">
<!--
function maskHp(obj) {
    var str = obj.value;
    if ( str ) {
        //var pattern = /[^(ㄱ-&#55203;)]|[-/\s]/g;
        var RegNotNum  = /[\D]/g;
        var pattern = "";
        var format   = "";

        // delete not number ㅋ
        str = str.replace(RegNotNum,'');

        //if( str.length < 4 ) return str;
        if( str.length < 4 ) {
            if( str.length == 3 ) {
                format = "$1";
                pattern = /(^01[\d]{0,1})/;
            } else {
                format = "$1";
                pattern = /(^0[1]?[\d]{0,1})/;
            }
        } else if( str.length > 3 && str.length < 7 ) {
            format = "$1-$2";
            pattern = /(^01[\d]{1})([\d]+)/;
        } else if(str.length == 7 ) {
            format = "$1-$2";
            pattern = /(^01[\d]{1})([\d]{4})/;
        } else {
            format = "$1-$2-$3";
            pattern = /(^01[\d]{1})([\d]{4})([\d]+)/;
        }

        //while( pattern.test(str) ) {
        if ( pattern.test(str) ) {
            obj.value = str.replace(pattern, format);
        } else {
            obj.value = "";
        }
    }
}


function isHpFormat() {
  var str = window.event.srcElement.value;
  //alert ( str );
  if ( window.event.propertyName == "value" && str ) {
        var pattern = "";
        str = str.replace(/[\D]/g,'');
        if( str.length < 4 ) {
            if( str.length == 3 ) pattern = /(^01[\d]{1})/;
            else                  pattern = /(^0[1]?[\d]{0,1})/;
        } else if( str.length > 3 && str.length < 7 ) {
            pattern = /(^01[\d]{1})([\d]+)$/;
        } else if(str.length == 7 ) {
            pattern = /(^01[\d]{1})([\d]{4})/;
        } else {
            pattern = /(^01[\d]{1})([\d]{4})([\d]+)/;
        }
        if ( pattern.test(str) ) {
            return true;
        } else {
            return false;
        }
  } else {
        return true;
      // undefined
  }
}

//-->
</SCRIPT>
<input type='text' id='phon_num' value=''
size='14' maxlength='13'
onpropertychange='if(!isHpFormat()){alert("핸드폰 번호가 정확히 입력해주세요.");this.value="";}'
onkeyup ='maskHp(this);'
onkeydown='maskHp(this);'  >


 

[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
16년 전 조회 5,879
16년 전 조회 1,926
16년 전 조회 3,691
16년 전 조회 1,476
16년 전 조회 1,763
16년 전 조회 2,078
16년 전 조회 2,620
16년 전 조회 2,317
16년 전 조회 2,758
16년 전 조회 3,001
16년 전 조회 3,021
16년 전 조회 1,824
16년 전 조회 1,551
16년 전 조회 1,419
16년 전 조회 1,734
16년 전 조회 1,216
16년 전 조회 1,974
16년 전 조회 1,746
16년 전 조회 1,619
16년 전 조회 1,306
16년 전 조회 2,180
16년 전 조회 3,239
16년 전 조회 2,172
16년 전 조회 1,749
16년 전 조회 1,519
16년 전 조회 2,052
17년 전 조회 4,738
17년 전 조회 1,421
17년 전 조회 2,159
17년 전 조회 2,139
17년 전 조회 2,411
17년 전 조회 2,159
17년 전 조회 4,445
17년 전 조회 2,942
17년 전 조회 2,878
17년 전 조회 1,609
17년 전 조회 1,249
17년 전 조회 3,955
17년 전 조회 1,627
17년 전 조회 1,619
17년 전 조회 2,123
17년 전 조회 1,893
17년 전 조회 1,507
17년 전 조회 3,926
17년 전 조회 1,765
17년 전 조회 3,138
17년 전 조회 3,017
17년 전 조회 1,050
17년 전 조회 1,859
17년 전 조회 1,604
17년 전 조회 1,860
17년 전 조회 2,652
17년 전 조회 3,034
17년 전 조회 3,227
17년 전 조회 3,336
17년 전 조회 1,470
17년 전 조회 1,427
17년 전 조회 2,264
17년 전 조회 1,987
17년 전 조회 2,301
17년 전 조회 2,827
17년 전 조회 3,275
17년 전 조회 2,373
17년 전 조회 1,644
17년 전 조회 3,215
17년 전 조회 3,079
17년 전 조회 3,055
17년 전 조회 3,922
17년 전 조회 2,598
17년 전 조회 2,419
17년 전 조회 2,667
17년 전 조회 2,905
17년 전 조회 2,619
17년 전 조회 1,464
17년 전 조회 1,909
17년 전 조회 1,500
17년 전 조회 1,923
17년 전 조회 2,522
17년 전 조회 8,703
17년 전 조회 3,164
17년 전 조회 4,254
17년 전 조회 1,989
17년 전 조회 3,670
17년 전 조회 1,565
17년 전 조회 1,396
17년 전 조회 2,331
17년 전 조회 1,326
17년 전 조회 1,642
17년 전 조회 1,475
17년 전 조회 2,543
17년 전 조회 1,510
17년 전 조회 1,100
17년 전 조회 1,232
17년 전 조회 3,109
17년 전 조회 2,174
17년 전 조회 1,981
17년 전 조회 1,225
17년 전 조회 2,456
17년 전 조회 1,180
17년 전 조회 1,138
🐛 버그신고