휴대폰번호 검사

· 17년 전 · 1585

<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,863
16년 전 조회 1,911
16년 전 조회 3,677
16년 전 조회 1,460
16년 전 조회 1,750
16년 전 조회 2,064
16년 전 조회 2,603
16년 전 조회 2,303
16년 전 조회 2,745
16년 전 조회 2,983
16년 전 조회 3,009
16년 전 조회 1,815
16년 전 조회 1,534
16년 전 조회 1,407
16년 전 조회 1,719
16년 전 조회 1,202
16년 전 조회 1,959
16년 전 조회 1,729
16년 전 조회 1,606
16년 전 조회 1,293
16년 전 조회 2,165
16년 전 조회 3,226
16년 전 조회 2,162
16년 전 조회 1,736
16년 전 조회 1,503
16년 전 조회 2,036
16년 전 조회 4,723
16년 전 조회 1,410
17년 전 조회 2,144
17년 전 조회 2,128
17년 전 조회 2,395
17년 전 조회 2,142
17년 전 조회 4,427
17년 전 조회 2,923
17년 전 조회 2,860
17년 전 조회 1,595
17년 전 조회 1,233
17년 전 조회 3,939
17년 전 조회 1,613
17년 전 조회 1,604
17년 전 조회 2,104
17년 전 조회 1,876
17년 전 조회 1,490
17년 전 조회 3,913
17년 전 조회 1,751
17년 전 조회 3,124
17년 전 조회 3,003
17년 전 조회 1,034
17년 전 조회 1,843
17년 전 조회 1,586
17년 전 조회 1,847
17년 전 조회 2,635
17년 전 조회 3,020
17년 전 조회 3,213
17년 전 조회 3,321
17년 전 조회 1,456
17년 전 조회 1,414
17년 전 조회 2,247
17년 전 조회 1,970
17년 전 조회 2,286
17년 전 조회 2,807
17년 전 조회 3,260
17년 전 조회 2,360
17년 전 조회 1,629
17년 전 조회 3,201
17년 전 조회 3,067
17년 전 조회 3,041
17년 전 조회 3,910
17년 전 조회 2,582
17년 전 조회 2,402
17년 전 조회 2,652
17년 전 조회 2,893
17년 전 조회 2,606
17년 전 조회 1,449
17년 전 조회 1,893
17년 전 조회 1,485
17년 전 조회 1,909
17년 전 조회 2,507
17년 전 조회 8,691
17년 전 조회 3,151
17년 전 조회 4,238
17년 전 조회 1,980
17년 전 조회 3,656
17년 전 조회 1,550
17년 전 조회 1,384
17년 전 조회 2,319
17년 전 조회 1,312
17년 전 조회 1,625
17년 전 조회 1,458
17년 전 조회 2,528
17년 전 조회 1,495
17년 전 조회 1,086
17년 전 조회 1,220
17년 전 조회 3,096
17년 전 조회 2,159
17년 전 조회 1,967
17년 전 조회 1,212
17년 전 조회 2,447
17년 전 조회 1,167
17년 전 조회 1,127
🐛 버그신고