휴대폰번호 검사

· 17년 전 · 1766

<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,063
16년 전 조회 2,078
16년 전 조회 3,854
16년 전 조회 1,621
16년 전 조회 1,910
16년 전 조회 2,257
16년 전 조회 2,788
16년 전 조회 2,486
16년 전 조회 2,923
16년 전 조회 3,166
16년 전 조회 3,175
16년 전 조회 1,977
16년 전 조회 1,693
17년 전 조회 1,562
17년 전 조회 1,890
17년 전 조회 1,376
17년 전 조회 2,123
17년 전 조회 1,900
17년 전 조회 1,762
17년 전 조회 1,458
17년 전 조회 2,346
17년 전 조회 3,399
17년 전 조회 2,307
17년 전 조회 1,901
17년 전 조회 1,683
17년 전 조회 2,210
17년 전 조회 4,886
17년 전 조회 1,620
17년 전 조회 2,343
17년 전 조회 2,317
17년 전 조회 2,600
17년 전 조회 2,302
17년 전 조회 4,628
17년 전 조회 3,124
17년 전 조회 3,032
17년 전 조회 1,758
17년 전 조회 1,402
17년 전 조회 4,137
17년 전 조회 1,817
17년 전 조회 1,799
17년 전 조회 2,286
17년 전 조회 2,039
17년 전 조회 1,688
17년 전 조회 4,105
17년 전 조회 1,921
17년 전 조회 3,280
17년 전 조회 3,195
17년 전 조회 1,176
17년 전 조회 2,018
17년 전 조회 1,767
17년 전 조회 2,011
17년 전 조회 2,831
17년 전 조회 3,191
17년 전 조회 3,410
17년 전 조회 3,503
17년 전 조회 1,610
17년 전 조회 1,598
17년 전 조회 2,406
17년 전 조회 2,152
17년 전 조회 2,441
17년 전 조회 2,979
17년 전 조회 3,457
17년 전 조회 2,548
17년 전 조회 1,811
17년 전 조회 3,390
17년 전 조회 3,247
17년 전 조회 3,223
17년 전 조회 4,092
17년 전 조회 2,734
17년 전 조회 2,583
17년 전 조회 2,842
17년 전 조회 3,078
17년 전 조회 2,799
17년 전 조회 1,631
17년 전 조회 2,036
17년 전 조회 1,639
17년 전 조회 2,086
17년 전 조회 2,704
17년 전 조회 8,873
17년 전 조회 3,323
17년 전 조회 4,388
17년 전 조회 2,157
17년 전 조회 3,821
17년 전 조회 1,726
17년 전 조회 1,534
17년 전 조회 2,468
17년 전 조회 1,474
17년 전 조회 1,784
17년 전 조회 1,625
17년 전 조회 2,703
17년 전 조회 1,659
17년 전 조회 1,247
17년 전 조회 1,388
17년 전 조회 3,277
17년 전 조회 2,315
17년 전 조회 2,123
17년 전 조회 1,380
17년 전 조회 2,601
17년 전 조회 1,330
17년 전 조회 1,287