휴대폰번호 검사

· 17년 전 · 1797

<SCRIPT LANGUAGE="JavaScript">
<!--
function maskHp(obj) {
    var str = obj.value;
    if ( str ) {
        //var pattern = /[^(ㄱ-힣)]|[-/\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년 전 조회 6,113
16년 전 조회 2,112
16년 전 조회 3,895
16년 전 조회 1,651
16년 전 조회 1,947
16년 전 조회 2,288
16년 전 조회 2,815
16년 전 조회 2,517
16년 전 조회 2,954
16년 전 조회 3,195
16년 전 조회 3,216
17년 전 조회 2,008
17년 전 조회 1,732
17년 전 조회 1,600
17년 전 조회 1,932
17년 전 조회 1,415
17년 전 조회 2,167
17년 전 조회 1,938
17년 전 조회 1,795
17년 전 조회 1,500
17년 전 조회 2,375
17년 전 조회 3,435
17년 전 조회 2,340
17년 전 조회 1,940
17년 전 조회 1,717
17년 전 조회 2,245
17년 전 조회 4,927
17년 전 조회 1,650
17년 전 조회 2,380
17년 전 조회 2,340
17년 전 조회 2,620
17년 전 조회 2,338
17년 전 조회 4,659
17년 전 조회 3,153
17년 전 조회 3,070
17년 전 조회 1,783
17년 전 조회 1,435
17년 전 조회 4,165
17년 전 조회 1,838
17년 전 조회 1,838
17년 전 조회 2,317
17년 전 조회 2,081
17년 전 조회 1,712
17년 전 조회 4,132
17년 전 조회 1,962
17년 전 조회 3,302
17년 전 조회 3,233
17년 전 조회 1,223
17년 전 조회 2,042
17년 전 조회 1,798
17년 전 조회 2,038
17년 전 조회 2,860
17년 전 조회 3,222
17년 전 조회 3,433
17년 전 조회 3,530
17년 전 조회 1,639
17년 전 조회 1,626
17년 전 조회 2,430
17년 전 조회 2,187
17년 전 조회 2,477
17년 전 조회 3,011
17년 전 조회 3,488
17년 전 조회 2,572
17년 전 조회 1,844
17년 전 조회 3,425
17년 전 조회 3,274
17년 전 조회 3,249
17년 전 조회 4,123
17년 전 조회 2,759
17년 전 조회 2,624
17년 전 조회 2,868
17년 전 조회 3,116
17년 전 조회 2,828
17년 전 조회 1,665
17년 전 조회 2,064
17년 전 조회 1,671
17년 전 조회 2,121
17년 전 조회 2,741
17년 전 조회 8,907
17년 전 조회 3,353
17년 전 조회 4,417
17년 전 조회 2,185
17년 전 조회 3,853
17년 전 조회 1,749
17년 전 조회 1,571
17년 전 조회 2,511
17년 전 조회 1,511
17년 전 조회 1,813
17년 전 조회 1,662
17년 전 조회 2,736
17년 전 조회 1,690
17년 전 조회 1,286
17년 전 조회 1,423
17년 전 조회 3,314
17년 전 조회 2,359
17년 전 조회 2,152
17년 전 조회 1,398
17년 전 조회 2,625
17년 전 조회 1,363
17년 전 조회 1,315