휴대폰번호 검사

· 17년 전 · 1833

<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,153
16년 전 조회 2,148
16년 전 조회 3,931
16년 전 조회 1,686
16년 전 조회 1,982
16년 전 조회 2,319
16년 전 조회 2,851
16년 전 조회 2,552
16년 전 조회 2,984
17년 전 조회 3,232
17년 전 조회 3,251
17년 전 조회 2,042
17년 전 조회 1,771
17년 전 조회 1,629
17년 전 조회 1,964
17년 전 조회 1,447
17년 전 조회 2,201
17년 전 조회 1,972
17년 전 조회 1,825
17년 전 조회 1,530
17년 전 조회 2,407
17년 전 조회 3,472
17년 전 조회 2,369
17년 전 조회 1,973
17년 전 조회 1,748
17년 전 조회 2,271
17년 전 조회 4,958
17년 전 조회 1,675
17년 전 조회 2,416
17년 전 조회 2,374
17년 전 조회 2,652
17년 전 조회 2,369
17년 전 조회 4,690
17년 전 조회 3,185
17년 전 조회 3,104
17년 전 조회 1,817
17년 전 조회 1,466
17년 전 조회 4,196
17년 전 조회 1,872
17년 전 조회 1,877
17년 전 조회 2,350
17년 전 조회 2,119
17년 전 조회 1,754
17년 전 조회 4,175
17년 전 조회 1,993
17년 전 조회 3,342
17년 전 조회 3,264
17년 전 조회 1,255
17년 전 조회 2,071
17년 전 조회 1,834
17년 전 조회 2,079
17년 전 조회 2,895
17년 전 조회 3,258
17년 전 조회 3,464
17년 전 조회 3,573
17년 전 조회 1,666
17년 전 조회 1,663
17년 전 조회 2,467
17년 전 조회 2,219
17년 전 조회 2,511
17년 전 조회 3,051
17년 전 조회 3,528
17년 전 조회 2,609
17년 전 조회 1,884
17년 전 조회 3,465
17년 전 조회 3,310
17년 전 조회 3,278
17년 전 조회 4,155
17년 전 조회 2,795
17년 전 조회 2,662
17년 전 조회 2,912
17년 전 조회 3,149
17년 전 조회 2,854
17년 전 조회 1,696
17년 전 조회 2,105
17년 전 조회 1,710
17년 전 조회 2,163
17년 전 조회 2,776
17년 전 조회 8,945
17년 전 조회 3,387
17년 전 조회 4,456
17년 전 조회 2,221
17년 전 조회 3,890
17년 전 조회 1,787
17년 전 조회 1,606
17년 전 조회 2,549
17년 전 조회 1,541
17년 전 조회 1,847
17년 전 조회 1,699
17년 전 조회 2,765
17년 전 조회 1,733
17년 전 조회 1,323
17년 전 조회 1,472
17년 전 조회 3,356
17년 전 조회 2,396
17년 전 조회 2,188
17년 전 조회 1,439
17년 전 조회 2,659
17년 전 조회 1,403
17년 전 조회 1,350