휴대폰번호 검사

· 17년 전 · 1963

<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,295
16년 전 조회 2,319
17년 전 조회 4,082
17년 전 조회 1,845
17년 전 조회 2,151
17년 전 조회 2,493
17년 전 조회 3,000
17년 전 조회 2,696
17년 전 조회 3,153
17년 전 조회 3,388
17년 전 조회 3,404
17년 전 조회 2,217
17년 전 조회 1,940
17년 전 조회 1,807
17년 전 조회 2,123
17년 전 조회 1,603
17년 전 조회 2,354
17년 전 조회 2,139
17년 전 조회 1,983
17년 전 조회 1,685
17년 전 조회 2,555
17년 전 조회 3,621
17년 전 조회 2,522
17년 전 조회 2,133
17년 전 조회 1,896
17년 전 조회 2,429
17년 전 조회 5,112
17년 전 조회 1,814
17년 전 조회 2,560
17년 전 조회 2,526
17년 전 조회 2,805
17년 전 조회 2,516
17년 전 조회 4,852
17년 전 조회 3,351
17년 전 조회 3,256
17년 전 조회 1,978
17년 전 조회 1,644
17년 전 조회 4,366
17년 전 조회 2,032
17년 전 조회 2,030
17년 전 조회 2,517
17년 전 조회 2,270
17년 전 조회 1,903
17년 전 조회 4,319
17년 전 조회 2,139
17년 전 조회 3,497
17년 전 조회 3,419
17년 전 조회 1,410
17년 전 조회 2,191
17년 전 조회 1,964
17년 전 조회 2,219
17년 전 조회 3,030
17년 전 조회 3,382
17년 전 조회 3,587
17년 전 조회 3,706
17년 전 조회 1,808
17년 전 조회 1,805
17년 전 조회 2,614
17년 전 조회 2,352
17년 전 조회 2,653
17년 전 조회 3,196
17년 전 조회 3,653
17년 전 조회 2,749
17년 전 조회 2,017
17년 전 조회 3,600
17년 전 조회 3,461
17년 전 조회 3,419
17년 전 조회 4,290
17년 전 조회 2,943
17년 전 조회 2,788
17년 전 조회 3,046
17년 전 조회 3,272
17년 전 조회 2,996
17년 전 조회 1,862
17년 전 조회 2,260
17년 전 조회 1,911
17년 전 조회 2,314
17년 전 조회 2,915
17년 전 조회 9,075
17년 전 조회 3,535
17년 전 조회 4,595
17년 전 조회 2,346
17년 전 조회 4,011
17년 전 조회 1,905
17년 전 조회 1,758
17년 전 조회 2,691
17년 전 조회 1,670
17년 전 조회 1,991
17년 전 조회 1,848
17년 전 조회 2,908
17년 전 조회 1,866
17년 전 조회 1,439
17년 전 조회 1,593
17년 전 조회 3,497
17년 전 조회 2,531
17년 전 조회 2,322
17년 전 조회 1,571
17년 전 조회 2,802
17년 전 조회 1,523
17년 전 조회 1,500