휴대폰번호 검사

· 17년 전 · 1878

<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,191
16년 전 조회 2,203
16년 전 조회 3,987
16년 전 조회 1,739
16년 전 조회 2,027
16년 전 조회 2,381
17년 전 조회 2,902
17년 전 조회 2,610
17년 전 조회 3,040
17년 전 조회 3,277
17년 전 조회 3,300
17년 전 조회 2,101
17년 전 조회 1,827
17년 전 조회 1,695
17년 전 조회 2,015
17년 전 조회 1,501
17년 전 조회 2,257
17년 전 조회 2,030
17년 전 조회 1,887
17년 전 조회 1,581
17년 전 조회 2,454
17년 전 조회 3,522
17년 전 조회 2,426
17년 전 조회 2,020
17년 전 조회 1,809
17년 전 조회 2,322
17년 전 조회 5,010
17년 전 조회 1,719
17년 전 조회 2,463
17년 전 조회 2,424
17년 전 조회 2,694
17년 전 조회 2,422
17년 전 조회 4,738
17년 전 조회 3,236
17년 전 조회 3,148
17년 전 조회 1,863
17년 전 조회 1,524
17년 전 조회 4,253
17년 전 조회 1,921
17년 전 조회 1,922
17년 전 조회 2,407
17년 전 조회 2,169
17년 전 조회 1,805
17년 전 조회 4,219
17년 전 조회 2,047
17년 전 조회 3,386
17년 전 조회 3,312
17년 전 조회 1,307
17년 전 조회 2,121
17년 전 조회 1,879
17년 전 조회 2,135
17년 전 조회 2,937
17년 전 조회 3,298
17년 전 조회 3,502
17년 전 조회 3,618
17년 전 조회 1,710
17년 전 조회 1,707
17년 전 조회 2,516
17년 전 조회 2,263
17년 전 조회 2,550
17년 전 조회 3,105
17년 전 조회 3,573
17년 전 조회 2,648
17년 전 조회 1,923
17년 전 조회 3,505
17년 전 조회 3,354
17년 전 조회 3,322
17년 전 조회 4,207
17년 전 조회 2,841
17년 전 조회 2,704
17년 전 조회 2,953
17년 전 조회 3,190
17년 전 조회 2,905
17년 전 조회 1,750
17년 전 조회 2,149
17년 전 조회 1,745
17년 전 조회 2,204
17년 전 조회 2,828
17년 전 조회 8,987
17년 전 조회 3,429
17년 전 조회 4,497
17년 전 조회 2,257
17년 전 조회 3,931
17년 전 조회 1,825
17년 전 조회 1,652
17년 전 조회 2,585
17년 전 조회 1,576
17년 전 조회 1,884
17년 전 조회 1,739
17년 전 조회 2,809
17년 전 조회 1,762
17년 전 조회 1,353
17년 전 조회 1,504
17년 전 조회 3,399
17년 전 조회 2,429
17년 전 조회 2,220
17년 전 조회 1,483
17년 전 조회 2,706
17년 전 조회 1,436
17년 전 조회 1,399