휴대폰번호 검사

· 17년 전 · 1587

<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,866
16년 전 조회 1,912
16년 전 조회 3,678
16년 전 조회 1,464
16년 전 조회 1,751
16년 전 조회 2,067
16년 전 조회 2,603
16년 전 조회 2,305
16년 전 조회 2,746
16년 전 조회 2,983
16년 전 조회 3,011
16년 전 조회 1,818
16년 전 조회 1,536
16년 전 조회 1,410
16년 전 조회 1,721
16년 전 조회 1,203
16년 전 조회 1,961
16년 전 조회 1,730
16년 전 조회 1,607
16년 전 조회 1,295
16년 전 조회 2,167
16년 전 조회 3,228
16년 전 조회 2,163
16년 전 조회 1,737
16년 전 조회 1,505
16년 전 조회 2,038
16년 전 조회 4,724
16년 전 조회 1,413
17년 전 조회 2,147
17년 전 조회 2,132
17년 전 조회 2,400
17년 전 조회 2,145
17년 전 조회 4,428
17년 전 조회 2,928
17년 전 조회 2,863
17년 전 조회 1,597
17년 전 조회 1,236
17년 전 조회 3,941
17년 전 조회 1,613
17년 전 조회 1,606
17년 전 조회 2,107
17년 전 조회 1,879
17년 전 조회 1,492
17년 전 조회 3,917
17년 전 조회 1,752
17년 전 조회 3,127
17년 전 조회 3,006
17년 전 조회 1,035
17년 전 조회 1,846
17년 전 조회 1,588
17년 전 조회 1,850
17년 전 조회 2,636
17년 전 조회 3,021
17년 전 조회 3,215
17년 전 조회 3,321
17년 전 조회 1,459
17년 전 조회 1,416
17년 전 조회 2,248
17년 전 조회 1,972
17년 전 조회 2,288
17년 전 조회 2,813
17년 전 조회 3,261
17년 전 조회 2,362
17년 전 조회 1,629
17년 전 조회 3,202
17년 전 조회 3,069
17년 전 조회 3,043
17년 전 조회 3,913
17년 전 조회 2,584
17년 전 조회 2,404
17년 전 조회 2,654
17년 전 조회 2,894
17년 전 조회 2,609
17년 전 조회 1,449
17년 전 조회 1,895
17년 전 조회 1,487
17년 전 조회 1,910
17년 전 조회 2,509
17년 전 조회 8,693
17년 전 조회 3,151
17년 전 조회 4,241
17년 전 조회 1,981
17년 전 조회 3,657
17년 전 조회 1,551
17년 전 조회 1,385
17년 전 조회 2,320
17년 전 조회 1,313
17년 전 조회 1,628
17년 전 조회 1,460
17년 전 조회 2,530
17년 전 조회 1,497
17년 전 조회 1,088
17년 전 조회 1,222
17년 전 조회 3,098
17년 전 조회 2,162
17년 전 조회 1,968
17년 전 조회 1,213
17년 전 조회 2,447
17년 전 조회 1,167
17년 전 조회 1,127
🐛 버그신고