휴대폰번호 검사

· 17년 전 · 1694

<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,963
16년 전 조회 2,003
16년 전 조회 3,774
16년 전 조회 1,550
16년 전 조회 1,835
16년 전 조회 2,158
16년 전 조회 2,699
16년 전 조회 2,399
16년 전 조회 2,833
16년 전 조회 3,081
16년 전 조회 3,099
16년 전 조회 1,899
16년 전 조회 1,629
16년 전 조회 1,488
16년 전 조회 1,811
16년 전 조회 1,291
16년 전 조회 2,057
16년 전 조회 1,829
17년 전 조회 1,698
17년 전 조회 1,385
17년 전 조회 2,259
17년 전 조회 3,317
17년 전 조회 2,238
17년 전 조회 1,826
17년 전 조회 1,600
17년 전 조회 2,130
17년 전 조회 4,809
17년 전 조회 1,504
17년 전 조회 2,240
17년 전 조회 2,212
17년 전 조회 2,491
17년 전 조회 2,231
17년 전 조회 4,525
17년 전 조회 3,023
17년 전 조회 2,959
17년 전 조회 1,674
17년 전 조회 1,321
17년 전 조회 4,047
17년 전 조회 1,707
17년 전 조회 1,707
17년 전 조회 2,209
17년 전 조회 1,968
17년 전 조회 1,596
17년 전 조회 4,013
17년 전 조회 1,843
17년 전 조회 3,213
17년 전 조회 3,104
17년 전 조회 1,125
17년 전 조회 1,937
17년 전 조회 1,695
17년 전 조회 1,942
17년 전 조회 2,721
17년 전 조회 3,115
17년 전 조회 3,308
17년 전 조회 3,422
17년 전 조회 1,549
17년 전 조회 1,510
17년 전 조회 2,333
17년 전 조회 2,066
17년 전 조회 2,380
17년 전 조회 2,905
17년 전 조회 3,356
17년 전 조회 2,452
17년 전 조회 1,721
17년 전 조회 3,297
17년 전 조회 3,154
17년 전 조회 3,136
17년 전 조회 4,008
17년 전 조회 2,669
17년 전 조회 2,489
17년 전 조회 2,741
17년 전 조회 2,982
17년 전 조회 2,696
17년 전 조회 1,533
17년 전 조회 1,976
17년 전 조회 1,569
17년 전 조회 1,998
17년 전 조회 2,601
17년 전 조회 8,778
17년 전 조회 3,250
17년 전 조회 4,329
17년 전 조회 2,072
17년 전 조회 3,748
17년 전 조회 1,644
17년 전 조회 1,463
17년 전 조회 2,409
17년 전 조회 1,390
17년 전 조회 1,712
17년 전 조회 1,553
17년 전 조회 2,614
17년 전 조회 1,577
17년 전 조회 1,177
17년 전 조회 1,312
17년 전 조회 3,199
17년 전 조회 2,249
17년 전 조회 2,058
17년 전 조회 1,294
17년 전 조회 2,527
17년 전 조회 1,250
17년 전 조회 1,222