휴대폰번호 검사

· 17년 전 · 1596

<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,876
16년 전 조회 1,920
16년 전 조회 3,689
16년 전 조회 1,472
16년 전 조회 1,759
16년 전 조회 2,073
16년 전 조회 2,617
16년 전 조회 2,314
16년 전 조회 2,753
16년 전 조회 2,998
16년 전 조회 3,019
16년 전 조회 1,822
16년 전 조회 1,547
16년 전 조회 1,417
16년 전 조회 1,728
16년 전 조회 1,212
16년 전 조회 1,971
16년 전 조회 1,741
16년 전 조회 1,614
16년 전 조회 1,301
16년 전 조회 2,176
16년 전 조회 3,236
16년 전 조회 2,167
16년 전 조회 1,745
16년 전 조회 1,514
16년 전 조회 2,050
16년 전 조회 4,733
17년 전 조회 1,420
17년 전 조회 2,157
17년 전 조회 2,134
17년 전 조회 2,409
17년 전 조회 2,155
17년 전 조회 4,440
17년 전 조회 2,935
17년 전 조회 2,871
17년 전 조회 1,606
17년 전 조회 1,245
17년 전 조회 3,952
17년 전 조회 1,624
17년 전 조회 1,616
17년 전 조회 2,116
17년 전 조회 1,887
17년 전 조회 1,504
17년 전 조회 3,924
17년 전 조회 1,760
17년 전 조회 3,135
17년 전 조회 3,013
17년 전 조회 1,046
17년 전 조회 1,854
17년 전 조회 1,597
17년 전 조회 1,858
17년 전 조회 2,649
17년 전 조회 3,028
17년 전 조회 3,226
17년 전 조회 3,332
17년 전 조회 1,466
17년 전 조회 1,426
17년 전 조회 2,260
17년 전 조회 1,984
17년 전 조회 2,295
17년 전 조회 2,822
17년 전 조회 3,268
17년 전 조회 2,370
17년 전 조회 1,638
17년 전 조회 3,211
17년 전 조회 3,075
17년 전 조회 3,051
17년 전 조회 3,918
17년 전 조회 2,594
17년 전 조회 2,414
17년 전 조회 2,663
17년 전 조회 2,901
17년 전 조회 2,618
17년 전 조회 1,460
17년 전 조회 1,904
17년 전 조회 1,496
17년 전 조회 1,920
17년 전 조회 2,519
17년 전 조회 8,701
17년 전 조회 3,162
17년 전 조회 4,249
17년 전 조회 1,987
17년 전 조회 3,665
17년 전 조회 1,559
17년 전 조회 1,391
17년 전 조회 2,331
17년 전 조회 1,323
17년 전 조회 1,637
17년 전 조회 1,472
17년 전 조회 2,538
17년 전 조회 1,506
17년 전 조회 1,097
17년 전 조회 1,232
17년 전 조회 3,105
17년 전 조회 2,169
17년 전 조회 1,978
17년 전 조회 1,221
17년 전 조회 2,455
17년 전 조회 1,174
17년 전 조회 1,133
🐛 버그신고