휴대폰번호 검사

· 17년 전 · 1589

<SCRIPT LANGUAGE="JavaScript">
<!--
function maskHp(obj) {
    var str = obj.value;
    if ( str ) {
        //var pattern = /[^(ㄱ-&#55203;)]|[-/\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,868
16년 전 조회 1,913
16년 전 조회 3,679
16년 전 조회 1,465
16년 전 조회 1,751
16년 전 조회 2,068
16년 전 조회 2,605
16년 전 조회 2,306
16년 전 조회 2,748
16년 전 조회 2,983
16년 전 조회 3,011
16년 전 조회 1,818
16년 전 조회 1,537
16년 전 조회 1,411
16년 전 조회 1,722
16년 전 조회 1,205
16년 전 조회 1,962
16년 전 조회 1,730
16년 전 조회 1,609
16년 전 조회 1,295
16년 전 조회 2,168
16년 전 조회 3,228
16년 전 조회 2,163
16년 전 조회 1,738
16년 전 조회 1,507
16년 전 조회 2,041
16년 전 조회 4,725
16년 전 조회 1,413
17년 전 조회 2,147
17년 전 조회 2,132
17년 전 조회 2,401
17년 전 조회 2,147
17년 전 조회 4,429
17년 전 조회 2,929
17년 전 조회 2,864
17년 전 조회 1,598
17년 전 조회 1,238
17년 전 조회 3,942
17년 전 조회 1,615
17년 전 조회 1,609
17년 전 조회 2,107
17년 전 조회 1,879
17년 전 조회 1,494
17년 전 조회 3,918
17년 전 조회 1,753
17년 전 조회 3,129
17년 전 조회 3,008
17년 전 조회 1,037
17년 전 조회 1,846
17년 전 조회 1,590
17년 전 조회 1,850
17년 전 조회 2,639
17년 전 조회 3,022
17년 전 조회 3,215
17년 전 조회 3,322
17년 전 조회 1,460
17년 전 조회 1,416
17년 전 조회 2,251
17년 전 조회 1,972
17년 전 조회 2,288
17년 전 조회 2,813
17년 전 조회 3,261
17년 전 조회 2,362
17년 전 조회 1,630
17년 전 조회 3,204
17년 전 조회 3,070
17년 전 조회 3,044
17년 전 조회 3,914
17년 전 조회 2,585
17년 전 조회 2,404
17년 전 조회 2,654
17년 전 조회 2,894
17년 전 조회 2,610
17년 전 조회 1,451
17년 전 조회 1,895
17년 전 조회 1,487
17년 전 조회 1,910
17년 전 조회 2,509
17년 전 조회 8,694
17년 전 조회 3,152
17년 전 조회 4,241
17년 전 조회 1,982
17년 전 조회 3,659
17년 전 조회 1,551
17년 전 조회 1,385
17년 전 조회 2,321
17년 전 조회 1,313
17년 전 조회 1,629
17년 전 조회 1,460
17년 전 조회 2,530
17년 전 조회 1,497
17년 전 조회 1,088
17년 전 조회 1,224
17년 전 조회 3,098
17년 전 조회 2,162
17년 전 조회 1,969
17년 전 조회 1,214
17년 전 조회 2,448
17년 전 조회 1,168
17년 전 조회 1,128
🐛 버그신고