휴대폰번호 검사

· 17년 전 · 1591

<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,871
16년 전 조회 1,918
16년 전 조회 3,686
16년 전 조회 1,465
16년 전 조회 1,756
16년 전 조회 2,071
16년 전 조회 2,611
16년 전 조회 2,310
16년 전 조회 2,750
16년 전 조회 2,992
16년 전 조회 3,016
16년 전 조회 1,821
16년 전 조회 1,542
16년 전 조회 1,413
16년 전 조회 1,725
16년 전 조회 1,207
16년 전 조회 1,967
16년 전 조회 1,736
16년 전 조회 1,612
16년 전 조회 1,300
16년 전 조회 2,172
16년 전 조회 3,232
16년 전 조회 2,165
16년 전 조회 1,743
16년 전 조회 1,511
16년 전 조회 2,045
16년 전 조회 4,728
17년 전 조회 1,415
17년 전 조회 2,152
17년 전 조회 2,132
17년 전 조회 2,405
17년 전 조회 2,152
17년 전 조회 4,433
17년 전 조회 2,934
17년 전 조회 2,867
17년 전 조회 1,602
17년 전 조회 1,242
17년 전 조회 3,947
17년 전 조회 1,617
17년 전 조회 1,613
17년 전 조회 2,112
17년 전 조회 1,882
17년 전 조회 1,496
17년 전 조회 3,919
17년 전 조회 1,759
17년 전 조회 3,130
17년 전 조회 3,010
17년 전 조회 1,042
17년 전 조회 1,850
17년 전 조회 1,592
17년 전 조회 1,853
17년 전 조회 2,643
17년 전 조회 3,023
17년 전 조회 3,218
17년 전 조회 3,327
17년 전 조회 1,463
17년 전 조회 1,420
17년 전 조회 2,253
17년 전 조회 1,978
17년 전 조회 2,290
17년 전 조회 2,816
17년 전 조회 3,265
17년 전 조회 2,367
17년 전 조회 1,634
17년 전 조회 3,208
17년 전 조회 3,073
17년 전 조회 3,047
17년 전 조회 3,915
17년 전 조회 2,589
17년 전 조회 2,407
17년 전 조회 2,658
17년 전 조회 2,896
17년 전 조회 2,612
17년 전 조회 1,455
17년 전 조회 1,899
17년 전 조회 1,490
17년 전 조회 1,915
17년 전 조회 2,514
17년 전 조회 8,698
17년 전 조회 3,158
17년 전 조회 4,246
17년 전 조회 1,984
17년 전 조회 3,661
17년 전 조회 1,555
17년 전 조회 1,386
17년 전 조회 2,322
17년 전 조회 1,317
17년 전 조회 1,632
17년 전 조회 1,466
17년 전 조회 2,534
17년 전 조회 1,502
17년 전 조회 1,092
17년 전 조회 1,228
17년 전 조회 3,100
17년 전 조회 2,164
17년 전 조회 1,971
17년 전 조회 1,217
17년 전 조회 2,451
17년 전 조회 1,170
17년 전 조회 1,130
🐛 버그신고