휴대폰번호 검사

· 17년 전 · 1624

<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,895
16년 전 조회 1,941
16년 전 조회 3,718
16년 전 조회 1,500
16년 전 조회 1,791
16년 전 조회 2,100
16년 전 조회 2,637
16년 전 조회 2,343
16년 전 조회 2,782
16년 전 조회 3,020
16년 전 조회 3,043
16년 전 조회 1,852
16년 전 조회 1,570
16년 전 조회 1,444
16년 전 조회 1,757
16년 전 조회 1,234
16년 전 조회 1,994
16년 전 조회 1,763
16년 전 조회 1,639
17년 전 조회 1,322
17년 전 조회 2,195
17년 전 조회 3,265
17년 전 조회 2,189
17년 전 조회 1,772
17년 전 조회 1,542
17년 전 조회 2,075
17년 전 조회 4,763
17년 전 조회 1,447
17년 전 조회 2,178
17년 전 조회 2,158
17년 전 조회 2,427
17년 전 조회 2,175
17년 전 조회 4,460
17년 전 조회 2,957
17년 전 조회 2,897
17년 전 조회 1,627
17년 전 조회 1,273
17년 전 조회 3,975
17년 전 조회 1,643
17년 전 조회 1,642
17년 전 조회 2,146
17년 전 조회 1,910
17년 전 조회 1,527
17년 전 조회 3,949
17년 전 조회 1,776
17년 전 조회 3,163
17년 전 조회 3,029
17년 전 조회 1,063
17년 전 조회 1,878
17년 전 조회 1,625
17년 전 조회 1,875
17년 전 조회 2,668
17년 전 조회 3,059
17년 전 조회 3,245
17년 전 조회 3,356
17년 전 조회 1,491
17년 전 조회 1,443
17년 전 조회 2,285
17년 전 조회 2,009
17년 전 조회 2,319
17년 전 조회 2,844
17년 전 조회 3,290
17년 전 조회 2,389
17년 전 조회 1,659
17년 전 조회 3,231
17년 전 조회 3,093
17년 전 조회 3,075
17년 전 조회 3,944
17년 전 조회 2,619
17년 전 조회 2,436
17년 전 조회 2,685
17년 전 조회 2,923
17년 전 조회 2,641
17년 전 조회 1,483
17년 전 조회 1,923
17년 전 조회 1,512
17년 전 조회 1,942
17년 전 조회 2,540
17년 전 조회 8,721
17년 전 조회 3,181
17년 전 조회 4,274
17년 전 조회 2,011
17년 전 조회 3,688
17년 전 조회 1,586
17년 전 조회 1,410
17년 전 조회 2,349
17년 전 조회 1,343
17년 전 조회 1,660
17년 전 조회 1,491
17년 전 조회 2,562
17년 전 조회 1,526
17년 전 조회 1,123
17년 전 조회 1,255
17년 전 조회 3,130
17년 전 조회 2,183
17년 전 조회 1,997
17년 전 조회 1,242
17년 전 조회 2,475
17년 전 조회 1,197
17년 전 조회 1,158