휴대폰번호 검사

· 17년 전 · 1935

<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,249
16년 전 조회 2,275
16년 전 조회 4,049
16년 전 조회 1,802
16년 전 조회 2,102
17년 전 조회 2,454
17년 전 조회 2,961
17년 전 조회 2,664
17년 전 조회 3,105
17년 전 조회 3,347
17년 전 조회 3,367
17년 전 조회 2,174
17년 전 조회 1,890
17년 전 조회 1,764
17년 전 조회 2,074
17년 전 조회 1,555
17년 전 조회 2,318
17년 전 조회 2,093
17년 전 조회 1,945
17년 전 조회 1,643
17년 전 조회 2,513
17년 전 조회 3,580
17년 전 조회 2,482
17년 전 조회 2,087
17년 전 조회 1,860
17년 전 조회 2,391
17년 전 조회 5,074
17년 전 조회 1,773
17년 전 조회 2,517
17년 전 조회 2,488
17년 전 조회 2,758
17년 전 조회 2,478
17년 전 조회 4,803
17년 전 조회 3,307
17년 전 조회 3,213
17년 전 조회 1,929
17년 전 조회 1,592
17년 전 조회 4,314
17년 전 조회 1,997
17년 전 조회 1,990
17년 전 조회 2,471
17년 전 조회 2,222
17년 전 조회 1,869
17년 전 조회 4,285
17년 전 조회 2,098
17년 전 조회 3,461
17년 전 조회 3,383
17년 전 조회 1,370
17년 전 조회 2,162
17년 전 조회 1,936
17년 전 조회 2,187
17년 전 조회 2,991
17년 전 조회 3,350
17년 전 조회 3,557
17년 전 조회 3,670
17년 전 조회 1,770
17년 전 조회 1,764
17년 전 조회 2,579
17년 전 조회 2,323
17년 전 조회 2,614
17년 전 조회 3,164
17년 전 조회 3,621
17년 전 조회 2,710
17년 전 조회 1,975
17년 전 조회 3,564
17년 전 조회 3,421
17년 전 조회 3,386
17년 전 조회 4,266
17년 전 조회 2,904
17년 전 조회 2,753
17년 전 조회 3,010
17년 전 조회 3,239
17년 전 조회 2,959
17년 전 조회 1,820
17년 전 조회 2,217
17년 전 조회 1,864
17년 전 조회 2,277
17년 전 조회 2,878
17년 전 조회 9,042
17년 전 조회 3,491
17년 전 조회 4,554
17년 전 조회 2,316
17년 전 조회 3,986
17년 전 조회 1,878
17년 전 조회 1,727
17년 전 조회 2,646
17년 전 조회 1,640
17년 전 조회 1,946
17년 전 조회 1,808
17년 전 조회 2,872
17년 전 조회 1,834
17년 전 조회 1,401
17년 전 조회 1,566
17년 전 조회 3,462
17년 전 조회 2,487
17년 전 조회 2,289
17년 전 조회 1,538
17년 전 조회 2,766
17년 전 조회 1,496
17년 전 조회 1,460