휴대폰번호 검사

· 17년 전 · 1642

<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,912
16년 전 조회 1,964
16년 전 조회 3,734
16년 전 조회 1,518
16년 전 조회 1,805
16년 전 조회 2,113
16년 전 조회 2,654
16년 전 조회 2,361
16년 전 조회 2,795
16년 전 조회 3,041
16년 전 조회 3,061
16년 전 조회 1,871
16년 전 조회 1,590
16년 전 조회 1,461
16년 전 조회 1,774
16년 전 조회 1,250
16년 전 조회 2,018
16년 전 조회 1,782
16년 전 조회 1,657
17년 전 조회 1,340
17년 전 조회 2,214
17년 전 조회 3,279
17년 전 조회 2,210
17년 전 조회 1,795
17년 전 조회 1,558
17년 전 조회 2,089
17년 전 조회 4,780
17년 전 조회 1,462
17년 전 조회 2,194
17년 전 조회 2,174
17년 전 조회 2,446
17년 전 조회 2,196
17년 전 조회 4,475
17년 전 조회 2,978
17년 전 조회 2,921
17년 전 조회 1,644
17년 전 조회 1,290
17년 전 조회 3,996
17년 전 조회 1,666
17년 전 조회 1,662
17년 전 조회 2,159
17년 전 조회 1,937
17년 전 조회 1,549
17년 전 조회 3,965
17년 전 조회 1,797
17년 전 조회 3,175
17년 전 조회 3,046
17년 전 조회 1,086
17년 전 조회 1,898
17년 전 조회 1,643
17년 전 조회 1,897
17년 전 조회 2,680
17년 전 조회 3,074
17년 전 조회 3,265
17년 전 조회 3,368
17년 전 조회 1,510
17년 전 조회 1,463
17년 전 조회 2,299
17년 전 조회 2,026
17년 전 조회 2,339
17년 전 조회 2,860
17년 전 조회 3,314
17년 전 조회 2,410
17년 전 조회 1,679
17년 전 조회 3,253
17년 전 조회 3,119
17년 전 조회 3,094
17년 전 조회 3,960
17년 전 조회 2,636
17년 전 조회 2,451
17년 전 조회 2,697
17년 전 조회 2,939
17년 전 조회 2,659
17년 전 조회 1,497
17년 전 조회 1,940
17년 전 조회 1,530
17년 전 조회 1,959
17년 전 조회 2,557
17년 전 조회 8,740
17년 전 조회 3,202
17년 전 조회 4,291
17년 전 조회 2,031
17년 전 조회 3,708
17년 전 조회 1,607
17년 전 조회 1,427
17년 전 조회 2,375
17년 전 조회 1,354
17년 전 조회 1,677
17년 전 조회 1,515
17년 전 조회 2,577
17년 전 조회 1,542
17년 전 조회 1,136
17년 전 조회 1,269
17년 전 조회 3,153
17년 전 조회 2,204
17년 전 조회 2,014
17년 전 조회 1,265
17년 전 조회 2,488
17년 전 조회 1,208
17년 전 조회 1,177