휴대폰번호 검사

· 17년 전 · 1592

<SCRIPT LANGUAGE="JavaScript">
<!--
function maskHp(obj) {
    var str = obj.value;
    if ( str ) {
        //var pattern = /[^(ㄱ-&#55203;)]|[-/\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,874
16년 전 조회 1,919
16년 전 조회 3,688
16년 전 조회 1,468
16년 전 조회 1,757
16년 전 조회 2,072
16년 전 조회 2,613
16년 전 조회 2,314
16년 전 조회 2,751
16년 전 조회 2,994
16년 전 조회 3,019
16년 전 조회 1,822
16년 전 조회 1,544
16년 전 조회 1,417
16년 전 조회 1,727
16년 전 조회 1,211
16년 전 조회 1,969
16년 전 조회 1,738
16년 전 조회 1,612
16년 전 조회 1,301
16년 전 조회 2,175
16년 전 조회 3,233
16년 전 조회 2,166
16년 전 조회 1,745
16년 전 조회 1,514
16년 전 조회 2,048
16년 전 조회 4,731
17년 전 조회 1,418
17년 전 조회 2,155
17년 전 조회 2,134
17년 전 조회 2,408
17년 전 조회 2,154
17년 전 조회 4,436
17년 전 조회 2,935
17년 전 조회 2,870
17년 전 조회 1,604
17년 전 조회 1,242
17년 전 조회 3,949
17년 전 조회 1,622
17년 전 조회 1,614
17년 전 조회 2,114
17년 전 조회 1,887
17년 전 조회 1,500
17년 전 조회 3,923
17년 전 조회 1,759
17년 전 조회 3,133
17년 전 조회 3,013
17년 전 조회 1,043
17년 전 조회 1,852
17년 전 조회 1,593
17년 전 조회 1,857
17년 전 조회 2,646
17년 전 조회 3,025
17년 전 조회 3,223
17년 전 조회 3,329
17년 전 조회 1,465
17년 전 조회 1,424
17년 전 조회 2,255
17년 전 조회 1,981
17년 전 조회 2,292
17년 전 조회 2,821
17년 전 조회 3,268
17년 전 조회 2,369
17년 전 조회 1,636
17년 전 조회 3,209
17년 전 조회 3,075
17년 전 조회 3,049
17년 전 조회 3,918
17년 전 조회 2,591
17년 전 조회 2,411
17년 전 조회 2,662
17년 전 조회 2,898
17년 전 조회 2,615
17년 전 조회 1,458
17년 전 조회 1,901
17년 전 조회 1,496
17년 전 조회 1,917
17년 전 조회 2,517
17년 전 조회 8,699
17년 전 조회 3,159
17년 전 조회 4,248
17년 전 조회 1,987
17년 전 조회 3,661
17년 전 조회 1,559
17년 전 조회 1,390
17년 전 조회 2,325
17년 전 조회 1,321
17년 전 조회 1,634
17년 전 조회 1,469
17년 전 조회 2,537
17년 전 조회 1,504
17년 전 조회 1,095
17년 전 조회 1,229
17년 전 조회 3,103
17년 전 조회 2,164
17년 전 조회 1,976
17년 전 조회 1,219
17년 전 조회 2,452
17년 전 조회 1,172
17년 전 조회 1,131
🐛 버그신고