휴대폰번호 검사

· 17년 전 · 1678

<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년 전 조회 5,944
16년 전 조회 1,989
16년 전 조회 3,759
16년 전 조회 1,541
16년 전 조회 1,827
16년 전 조회 2,143
16년 전 조회 2,687
16년 전 조회 2,385
16년 전 조회 2,824
16년 전 조회 3,064
16년 전 조회 3,087
16년 전 조회 1,890
16년 전 조회 1,610
16년 전 조회 1,478
16년 전 조회 1,795
16년 전 조회 1,277
16년 전 조회 2,041
16년 전 조회 1,814
17년 전 조회 1,679
17년 전 조회 1,370
17년 전 조회 2,240
17년 전 조회 3,306
17년 전 조회 2,228
17년 전 조회 1,817
17년 전 조회 1,582
17년 전 조회 2,112
17년 전 조회 4,798
17년 전 조회 1,491
17년 전 조회 2,221
17년 전 조회 2,192
17년 전 조회 2,473
17년 전 조회 2,217
17년 전 조회 4,508
17년 전 조회 3,005
17년 전 조회 2,947
17년 전 조회 1,662
17년 전 조회 1,309
17년 전 조회 4,032
17년 전 조회 1,687
17년 전 조회 1,690
17년 전 조회 2,186
17년 전 조회 1,957
17년 전 조회 1,582
17년 전 조회 3,990
17년 전 조회 1,827
17년 전 조회 3,205
17년 전 조회 3,084
17년 전 조회 1,112
17년 전 조회 1,919
17년 전 조회 1,679
17년 전 조회 1,926
17년 전 조회 2,709
17년 전 조회 3,107
17년 전 조회 3,285
17년 전 조회 3,401
17년 전 조회 1,538
17년 전 조회 1,494
17년 전 조회 2,320
17년 전 조회 2,048
17년 전 조회 2,367
17년 전 조회 2,884
17년 전 조회 3,337
17년 전 조회 2,431
17년 전 조회 1,697
17년 전 조회 3,285
17년 전 조회 3,139
17년 전 조회 3,117
17년 전 조회 3,984
17년 전 조회 2,662
17년 전 조회 2,478
17년 전 조회 2,724
17년 전 조회 2,971
17년 전 조회 2,681
17년 전 조회 1,517
17년 전 조회 1,962
17년 전 조회 1,555
17년 전 조회 1,984
17년 전 조회 2,587
17년 전 조회 8,761
17년 전 조회 3,231
17년 전 조회 4,316
17년 전 조회 2,061
17년 전 조회 3,738
17년 전 조회 1,630
17년 전 조회 1,453
17년 전 조회 2,395
17년 전 조회 1,380
17년 전 조회 1,699
17년 전 조회 1,540
17년 전 조회 2,602
17년 전 조회 1,564
17년 전 조회 1,164
17년 전 조회 1,299
17년 전 조회 3,179
17년 전 조회 2,242
17년 전 조회 2,042
17년 전 조회 1,285
17년 전 조회 2,512
17년 전 조회 1,233
17년 전 조회 1,203