휴대폰번호 검사

· 17년 전 · 1632

<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,904
16년 전 조회 1,954
16년 전 조회 3,724
16년 전 조회 1,506
16년 전 조회 1,797
16년 전 조회 2,108
16년 전 조회 2,641
16년 전 조회 2,351
16년 전 조회 2,785
16년 전 조회 3,027
16년 전 조회 3,049
16년 전 조회 1,863
16년 전 조회 1,580
16년 전 조회 1,454
16년 전 조회 1,767
16년 전 조회 1,240
16년 전 조회 2,005
16년 전 조회 1,769
16년 전 조회 1,648
17년 전 조회 1,327
17년 전 조회 2,202
17년 전 조회 3,273
17년 전 조회 2,200
17년 전 조회 1,777
17년 전 조회 1,549
17년 전 조회 2,084
17년 전 조회 4,771
17년 전 조회 1,457
17년 전 조회 2,187
17년 전 조회 2,165
17년 전 조회 2,434
17년 전 조회 2,184
17년 전 조회 4,468
17년 전 조회 2,967
17년 전 조회 2,908
17년 전 조회 1,634
17년 전 조회 1,282
17년 전 조회 3,987
17년 전 조회 1,654
17년 전 조회 1,652
17년 전 조회 2,152
17년 전 조회 1,922
17년 전 조회 1,535
17년 전 조회 3,955
17년 전 조회 1,787
17년 전 조회 3,169
17년 전 조회 3,039
17년 전 조회 1,075
17년 전 조회 1,885
17년 전 조회 1,633
17년 전 조회 1,884
17년 전 조회 2,675
17년 전 조회 3,066
17년 전 조회 3,254
17년 전 조회 3,362
17년 전 조회 1,502
17년 전 조회 1,454
17년 전 조회 2,291
17년 전 조회 2,015
17년 전 조회 2,324
17년 전 조회 2,849
17년 전 조회 3,299
17년 전 조회 2,397
17년 전 조회 1,669
17년 전 조회 3,243
17년 전 조회 3,107
17년 전 조회 3,083
17년 전 조회 3,954
17년 전 조회 2,629
17년 전 조회 2,446
17년 전 조회 2,690
17년 전 조회 2,929
17년 전 조회 2,647
17년 전 조회 1,490
17년 전 조회 1,931
17년 전 조회 1,519
17년 전 조회 1,948
17년 전 조회 2,551
17년 전 조회 8,731
17년 전 조회 3,190
17년 전 조회 4,284
17년 전 조회 2,018
17년 전 조회 3,697
17년 전 조회 1,595
17년 전 조회 1,417
17년 전 조회 2,357
17년 전 조회 1,350
17년 전 조회 1,673
17년 전 조회 1,503
17년 전 조회 2,567
17년 전 조회 1,535
17년 전 조회 1,131
17년 전 조회 1,259
17년 전 조회 3,142
17년 전 조회 2,190
17년 전 조회 2,004
17년 전 조회 1,252
17년 전 조회 2,481
17년 전 조회 1,204
17년 전 조회 1,171