휴대폰번호 검사

· 17년 전 · 1733

<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,034
16년 전 조회 2,045
16년 전 조회 3,832
16년 전 조회 1,587
16년 전 조회 1,878
16년 전 조회 2,234
16년 전 조회 2,760
16년 전 조회 2,450
16년 전 조회 2,887
16년 전 조회 3,129
16년 전 조회 3,149
16년 전 조회 1,959
16년 전 조회 1,675
17년 전 조회 1,533
17년 전 조회 1,849
17년 전 조회 1,342
17년 전 조회 2,096
17년 전 조회 1,870
17년 전 조회 1,731
17년 전 조회 1,422
17년 전 조회 2,311
17년 전 조회 3,372
17년 전 조회 2,287
17년 전 조회 1,872
17년 전 조회 1,652
17년 전 조회 2,185
17년 전 조회 4,853
17년 전 조회 1,581
17년 전 조회 2,320
17년 전 조회 2,288
17년 전 조회 2,575
17년 전 조회 2,275
17년 전 조회 4,602
17년 전 조회 3,095
17년 전 조회 3,000
17년 전 조회 1,728
17년 전 조회 1,367
17년 전 조회 4,112
17년 전 조회 1,786
17년 전 조회 1,772
17년 전 조회 2,255
17년 전 조회 2,007
17년 전 조회 1,661
17년 전 조회 4,080
17년 전 조회 1,898
17년 전 조회 3,250
17년 전 조회 3,160
17년 전 조회 1,155
17년 전 조회 1,993
17년 전 조회 1,734
17년 전 조회 1,982
17년 전 조회 2,795
17년 전 조회 3,162
17년 전 조회 3,375
17년 전 조회 3,477
17년 전 조회 1,582
17년 전 조회 1,566
17년 전 조회 2,377
17년 전 조회 2,123
17년 전 조회 2,418
17년 전 조회 2,949
17년 전 조회 3,431
17년 전 조회 2,520
17년 전 조회 1,785
17년 전 조회 3,367
17년 전 조회 3,220
17년 전 조회 3,197
17년 전 조회 4,058
17년 전 조회 2,712
17년 전 조회 2,552
17년 전 조회 2,817
17년 전 조회 3,051
17년 전 조회 2,763
17년 전 조회 1,598
17년 전 조회 2,013
17년 전 조회 1,612
17년 전 조회 2,062
17년 전 조회 2,664
17년 전 조회 8,837
17년 전 조회 3,293
17년 전 조회 4,363
17년 전 조회 2,128
17년 전 조회 3,794
17년 전 조회 1,705
17년 전 조회 1,516
17년 전 조회 2,445
17년 전 조회 1,453
17년 전 조회 1,755
17년 전 조회 1,599
17년 전 조회 2,677
17년 전 조회 1,625
17년 전 조회 1,224
17년 전 조회 1,362
17년 전 조회 3,251
17년 전 조회 2,289
17년 전 조회 2,089
17년 전 조회 1,345
17년 전 조회 2,573
17년 전 조회 1,299
17년 전 조회 1,255