휴대폰번호 검사

· 17년 전 · 1799

<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,119
16년 전 조회 2,112
16년 전 조회 3,899
16년 전 조회 1,655
16년 전 조회 1,949
16년 전 조회 2,293
16년 전 조회 2,818
16년 전 조회 2,520
16년 전 조회 2,956
16년 전 조회 3,201
16년 전 조회 3,218
17년 전 조회 2,009
17년 전 조회 1,737
17년 전 조회 1,603
17년 전 조회 1,935
17년 전 조회 1,418
17년 전 조회 2,170
17년 전 조회 1,942
17년 전 조회 1,799
17년 전 조회 1,501
17년 전 조회 2,376
17년 전 조회 3,439
17년 전 조회 2,342
17년 전 조회 1,941
17년 전 조회 1,717
17년 전 조회 2,246
17년 전 조회 4,933
17년 전 조회 1,651
17년 전 조회 2,384
17년 전 조회 2,345
17년 전 조회 2,625
17년 전 조회 2,341
17년 전 조회 4,663
17년 전 조회 3,156
17년 전 조회 3,075
17년 전 조회 1,784
17년 전 조회 1,435
17년 전 조회 4,168
17년 전 조회 1,840
17년 전 조회 1,841
17년 전 조회 2,320
17년 전 조회 2,084
17년 전 조회 1,721
17년 전 조회 4,140
17년 전 조회 1,965
17년 전 조회 3,305
17년 전 조회 3,236
17년 전 조회 1,224
17년 전 조회 2,044
17년 전 조회 1,800
17년 전 조회 2,043
17년 전 조회 2,861
17년 전 조회 3,225
17년 전 조회 3,435
17년 전 조회 3,535
17년 전 조회 1,642
17년 전 조회 1,630
17년 전 조회 2,430
17년 전 조회 2,193
17년 전 조회 2,480
17년 전 조회 3,013
17년 전 조회 3,495
17년 전 조회 2,578
17년 전 조회 1,851
17년 전 조회 3,431
17년 전 조회 3,278
17년 전 조회 3,253
17년 전 조회 4,126
17년 전 조회 2,763
17년 전 조회 2,628
17년 전 조회 2,874
17년 전 조회 3,117
17년 전 조회 2,831
17년 전 조회 1,670
17년 전 조회 2,072
17년 전 조회 1,674
17년 전 조회 2,127
17년 전 조회 2,744
17년 전 조회 8,912
17년 전 조회 3,357
17년 전 조회 4,422
17년 전 조회 2,187
17년 전 조회 3,858
17년 전 조회 1,754
17년 전 조회 1,573
17년 전 조회 2,514
17년 전 조회 1,513
17년 전 조회 1,813
17년 전 조회 1,664
17년 전 조회 2,737
17년 전 조회 1,692
17년 전 조회 1,291
17년 전 조회 1,429
17년 전 조회 3,319
17년 전 조회 2,363
17년 전 조회 2,156
17년 전 조회 1,403
17년 전 조회 2,627
17년 전 조회 1,364
17년 전 조회 1,320