휴대폰번호 검사

· 17년 전 · 1693

<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,960
16년 전 조회 2,001
16년 전 조회 3,772
16년 전 조회 1,548
16년 전 조회 1,834
16년 전 조회 2,155
16년 전 조회 2,698
16년 전 조회 2,392
16년 전 조회 2,831
16년 전 조회 3,077
16년 전 조회 3,098
16년 전 조회 1,898
16년 전 조회 1,625
16년 전 조회 1,486
16년 전 조회 1,808
16년 전 조회 1,287
16년 전 조회 2,054
16년 전 조회 1,827
17년 전 조회 1,696
17년 전 조회 1,382
17년 전 조회 2,256
17년 전 조회 3,316
17년 전 조회 2,235
17년 전 조회 1,825
17년 전 조회 1,594
17년 전 조회 2,128
17년 전 조회 4,808
17년 전 조회 1,502
17년 전 조회 2,237
17년 전 조회 2,203
17년 전 조회 2,489
17년 전 조회 2,230
17년 전 조회 4,520
17년 전 조회 3,021
17년 전 조회 2,958
17년 전 조회 1,674
17년 전 조회 1,319
17년 전 조회 4,045
17년 전 조회 1,700
17년 전 조회 1,704
17년 전 조회 2,207
17년 전 조회 1,967
17년 전 조회 1,590
17년 전 조회 4,010
17년 전 조회 1,839
17년 전 조회 3,212
17년 전 조회 3,102
17년 전 조회 1,123
17년 전 조회 1,936
17년 전 조회 1,694
17년 전 조회 1,939
17년 전 조회 2,720
17년 전 조회 3,114
17년 전 조회 3,300
17년 전 조회 3,416
17년 전 조회 1,548
17년 전 조회 1,506
17년 전 조회 2,328
17년 전 조회 2,063
17년 전 조회 2,374
17년 전 조회 2,901
17년 전 조회 3,352
17년 전 조회 2,450
17년 전 조회 1,717
17년 전 조회 3,296
17년 전 조회 3,152
17년 전 조회 3,133
17년 전 조회 4,000
17년 전 조회 2,667
17년 전 조회 2,485
17년 전 조회 2,736
17년 전 조회 2,980
17년 전 조회 2,693
17년 전 조회 1,526
17년 전 조회 1,975
17년 전 조회 1,565
17년 전 조회 1,994
17년 전 조회 2,600
17년 전 조회 8,772
17년 전 조회 3,246
17년 전 조회 4,326
17년 전 조회 2,071
17년 전 조회 3,748
17년 전 조회 1,641
17년 전 조회 1,461
17년 전 조회 2,407
17년 전 조회 1,390
17년 전 조회 1,710
17년 전 조회 1,552
17년 전 조회 2,612
17년 전 조회 1,576
17년 전 조회 1,174
17년 전 조회 1,308
17년 전 조회 3,196
17년 전 조회 2,249
17년 전 조회 2,055
17년 전 조회 1,289
17년 전 조회 2,522
17년 전 조회 1,250
17년 전 조회 1,219