휴대폰번호 검사

· 17년 전 · 1654

<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,915
16년 전 조회 1,965
16년 전 조회 3,736
16년 전 조회 1,522
16년 전 조회 1,810
16년 전 조회 2,119
16년 전 조회 2,659
16년 전 조회 2,365
16년 전 조회 2,798
16년 전 조회 3,043
16년 전 조회 3,066
16년 전 조회 1,875
16년 전 조회 1,594
16년 전 조회 1,465
16년 전 조회 1,782
16년 전 조회 1,258
16년 전 조회 2,020
16년 전 조회 1,787
17년 전 조회 1,661
17년 전 조회 1,343
17년 전 조회 2,220
17년 전 조회 3,282
17년 전 조회 2,210
17년 전 조회 1,797
17년 전 조회 1,560
17년 전 조회 2,092
17년 전 조회 4,781
17년 전 조회 1,467
17년 전 조회 2,195
17년 전 조회 2,176
17년 전 조회 2,452
17년 전 조회 2,197
17년 전 조회 4,479
17년 전 조회 2,980
17년 전 조회 2,923
17년 전 조회 1,645
17년 전 조회 1,294
17년 전 조회 3,998
17년 전 조회 1,668
17년 전 조회 1,667
17년 전 조회 2,163
17년 전 조회 1,940
17년 전 조회 1,559
17년 전 조회 3,969
17년 전 조회 1,800
17년 전 조회 3,182
17년 전 조회 3,052
17년 전 조회 1,089
17년 전 조회 1,902
17년 전 조회 1,655
17년 전 조회 1,901
17년 전 조회 2,688
17년 전 조회 3,077
17년 전 조회 3,268
17년 전 조회 3,371
17년 전 조회 1,514
17년 전 조회 1,471
17년 전 조회 2,304
17년 전 조회 2,026
17년 전 조회 2,345
17년 전 조회 2,864
17년 전 조회 3,319
17년 전 조회 2,412
17년 전 조회 1,680
17년 전 조회 3,259
17년 전 조회 3,120
17년 전 조회 3,098
17년 전 조회 3,964
17년 전 조회 2,639
17년 전 조회 2,453
17년 전 조회 2,701
17년 전 조회 2,943
17년 전 조회 2,663
17년 전 조회 1,502
17년 전 조회 1,942
17년 전 조회 1,531
17년 전 조회 1,964
17년 전 조회 2,559
17년 전 조회 8,743
17년 전 조회 3,208
17년 전 조회 4,296
17년 전 조회 2,036
17년 전 조회 3,712
17년 전 조회 1,613
17년 전 조회 1,431
17년 전 조회 2,376
17년 전 조회 1,356
17년 전 조회 1,680
17년 전 조회 1,518
17년 전 조회 2,578
17년 전 조회 1,545
17년 전 조회 1,143
17년 전 조회 1,274
17년 전 조회 3,154
17년 전 조회 2,208
17년 전 조회 2,015
17년 전 조회 1,269
17년 전 조회 2,491
17년 전 조회 1,210
17년 전 조회 1,182