휴대폰번호 검사

· 17년 전 · 1823

<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년 전 조회 6,144
16년 전 조회 2,136
16년 전 조회 3,918
16년 전 조회 1,675
16년 전 조회 1,973
16년 전 조회 2,314
16년 전 조회 2,843
16년 전 조회 2,541
16년 전 조회 2,973
17년 전 조회 3,221
17년 전 조회 3,237
17년 전 조회 2,033
17년 전 조회 1,759
17년 전 조회 1,622
17년 전 조회 1,958
17년 전 조회 1,434
17년 전 조회 2,190
17년 전 조회 1,965
17년 전 조회 1,819
17년 전 조회 1,525
17년 전 조회 2,394
17년 전 조회 3,462
17년 전 조회 2,360
17년 전 조회 1,962
17년 전 조회 1,736
17년 전 조회 2,262
17년 전 조회 4,949
17년 전 조회 1,671
17년 전 조회 2,407
17년 전 조회 2,367
17년 전 조회 2,644
17년 전 조회 2,355
17년 전 조회 4,679
17년 전 조회 3,179
17년 전 조회 3,094
17년 전 조회 1,803
17년 전 조회 1,459
17년 전 조회 4,191
17년 전 조회 1,863
17년 전 조회 1,866
17년 전 조회 2,341
17년 전 조회 2,108
17년 전 조회 1,739
17년 전 조회 4,163
17년 전 조회 1,986
17년 전 조회 3,327
17년 전 조회 3,256
17년 전 조회 1,245
17년 전 조회 2,062
17년 전 조회 1,824
17년 전 조회 2,071
17년 전 조회 2,886
17년 전 조회 3,247
17년 전 조회 3,454
17년 전 조회 3,561
17년 전 조회 1,663
17년 전 조회 1,651
17년 전 조회 2,457
17년 전 조회 2,210
17년 전 조회 2,496
17년 전 조회 3,042
17년 전 조회 3,517
17년 전 조회 2,599
17년 전 조회 1,873
17년 전 조회 3,454
17년 전 조회 3,301
17년 전 조회 3,267
17년 전 조회 4,139
17년 전 조회 2,788
17년 전 조회 2,649
17년 전 조회 2,898
17년 전 조회 3,134
17년 전 조회 2,847
17년 전 조회 1,685
17년 전 조회 2,096
17년 전 조회 1,705
17년 전 조회 2,149
17년 전 조회 2,771
17년 전 조회 8,936
17년 전 조회 3,379
17년 전 조회 4,442
17년 전 조회 2,210
17년 전 조회 3,882
17년 전 조회 1,782
17년 전 조회 1,597
17년 전 조회 2,539
17년 전 조회 1,533
17년 전 조회 1,831
17년 전 조회 1,688
17년 전 조회 2,758
17년 전 조회 1,721
17년 전 조회 1,311
17년 전 조회 1,460
17년 전 조회 3,343
17년 전 조회 2,386
17년 전 조회 2,182
17년 전 조회 1,431
17년 전 조회 2,654
17년 전 조회 1,392
17년 전 조회 1,343