휴대폰번호 검사

· 17년 전 · 1712

<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,008
16년 전 조회 2,024
16년 전 조회 3,803
16년 전 조회 1,566
16년 전 조회 1,857
16년 전 조회 2,211
16년 전 조회 2,735
16년 전 조회 2,431
16년 전 조회 2,863
16년 전 조회 3,106
16년 전 조회 3,122
16년 전 조회 1,930
16년 전 조회 1,652
17년 전 조회 1,513
17년 전 조회 1,831
17년 전 조회 1,320
17년 전 조회 2,078
17년 전 조회 1,850
17년 전 조회 1,715
17년 전 조회 1,404
17년 전 조회 2,293
17년 전 조회 3,349
17년 전 조회 2,271
17년 전 조회 1,855
17년 전 조회 1,629
17년 전 조회 2,157
17년 전 조회 4,838
17년 전 조회 1,556
17년 전 조회 2,295
17년 전 조회 2,269
17년 전 조회 2,542
17년 전 조회 2,251
17년 전 조회 4,574
17년 전 조회 3,070
17년 전 조회 2,984
17년 전 조회 1,704
17년 전 조회 1,348
17년 전 조회 4,091
17년 전 조회 1,755
17년 전 조회 1,748
17년 전 조회 2,236
17년 전 조회 1,986
17년 전 조회 1,638
17년 전 조회 4,056
17년 전 조회 1,878
17년 전 조회 3,230
17년 전 조회 3,139
17년 전 조회 1,139
17년 전 조회 1,971
17년 전 조회 1,713
17년 전 조회 1,960
17년 전 조회 2,775
17년 전 조회 3,142
17년 전 조회 3,348
17년 전 조회 3,458
17년 전 조회 1,567
17년 전 조회 1,543
17년 전 조회 2,361
17년 전 조회 2,100
17년 전 조회 2,398
17년 전 조회 2,929
17년 전 조회 3,401
17년 전 조회 2,491
17년 전 조회 1,766
17년 전 조회 3,336
17년 전 조회 3,194
17년 전 조회 3,171
17년 전 조회 4,043
17년 전 조회 2,690
17년 전 조회 2,529
17년 전 조회 2,783
17년 전 조회 3,022
17년 전 조회 2,741
17년 전 조회 1,570
17년 전 조회 1,998
17년 전 조회 1,599
17년 전 조회 2,039
17년 전 조회 2,638
17년 전 조회 8,810
17년 전 조회 3,273
17년 전 조회 4,347
17년 전 조회 2,105
17년 전 조회 3,777
17년 전 조회 1,682
17년 전 조회 1,494
17년 전 조회 2,431
17년 전 조회 1,424
17년 전 조회 1,740
17년 전 조회 1,584
17년 전 조회 2,650
17년 전 조회 1,607
17년 전 조회 1,202
17년 전 조회 1,342
17년 전 조회 3,224
17년 전 조회 2,268
17년 전 조회 2,075
17년 전 조회 1,322
17년 전 조회 2,547
17년 전 조회 1,276
17년 전 조회 1,246