휴대폰번호 검사

· 17년 전 · 1614

<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,885
16년 전 조회 1,935
16년 전 조회 3,705
16년 전 조회 1,488
16년 전 조회 1,777
16년 전 조회 2,087
16년 전 조회 2,629
16년 전 조회 2,329
16년 전 조회 2,770
16년 전 조회 3,012
16년 전 조회 3,034
16년 전 조회 1,841
16년 전 조회 1,562
16년 전 조회 1,435
16년 전 조회 1,748
16년 전 조회 1,223
16년 전 조회 1,987
16년 전 조회 1,755
16년 전 조회 1,629
17년 전 조회 1,312
17년 전 조회 2,191
17년 전 조회 3,254
17년 전 조회 2,181
17년 전 조회 1,759
17년 전 조회 1,532
17년 전 조회 2,063
17년 전 조회 4,752
17년 전 조회 1,435
17년 전 조회 2,167
17년 전 조회 2,151
17년 전 조회 2,423
17년 전 조회 2,170
17년 전 조회 4,457
17년 전 조회 2,949
17년 전 조회 2,889
17년 전 조회 1,617
17년 전 조회 1,262
17년 전 조회 3,966
17년 전 조회 1,636
17년 전 조회 1,633
17년 전 조회 2,133
17년 전 조회 1,905
17년 전 조회 1,521
17년 전 조회 3,938
17년 전 조회 1,773
17년 전 조회 3,157
17년 전 조회 3,023
17년 전 조회 1,057
17년 전 조회 1,870
17년 전 조회 1,615
17년 전 조회 1,865
17년 전 조회 2,658
17년 전 조회 3,041
17년 전 조회 3,238
17년 전 조회 3,348
17년 전 조회 1,482
17년 전 조회 1,437
17년 전 조회 2,277
17년 전 조회 2,002
17년 전 조회 2,310
17년 전 조회 2,835
17년 전 조회 3,284
17년 전 조회 2,378
17년 전 조회 1,652
17년 전 조회 3,226
17년 전 조회 3,089
17년 전 조회 3,067
17년 전 조회 3,936
17년 전 조회 2,608
17년 전 조회 2,430
17년 전 조회 2,678
17년 전 조회 2,917
17년 전 조회 2,635
17년 전 조회 1,474
17년 전 조회 1,917
17년 전 조회 1,509
17년 전 조회 1,934
17년 전 조회 2,529
17년 전 조회 8,715
17년 전 조회 3,172
17년 전 조회 4,268
17년 전 조회 2,004
17년 전 조회 3,676
17년 전 조회 1,578
17년 전 조회 1,406
17년 전 조회 2,343
17년 전 조회 1,334
17년 전 조회 1,652
17년 전 조회 1,485
17년 전 조회 2,553
17년 전 조회 1,518
17년 전 조회 1,115
17년 전 조회 1,246
17년 전 조회 3,122
17년 전 조회 2,179
17년 전 조회 1,993
17년 전 조회 1,233
17년 전 조회 2,468
17년 전 조회 1,190
17년 전 조회 1,149