휴대폰번호 검사

· 17년 전 · 1634

<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,909
16년 전 조회 1,955
16년 전 조회 3,725
16년 전 조회 1,508
16년 전 조회 1,799
16년 전 조회 2,108
16년 전 조회 2,644
16년 전 조회 2,354
16년 전 조회 2,787
16년 전 조회 3,032
16년 전 조회 3,051
16년 전 조회 1,864
16년 전 조회 1,582
16년 전 조회 1,457
16년 전 조회 1,768
16년 전 조회 1,242
16년 전 조회 2,007
16년 전 조회 1,771
16년 전 조회 1,650
17년 전 조회 1,328
17년 전 조회 2,206
17년 전 조회 3,273
17년 전 조회 2,205
17년 전 조회 1,782
17년 전 조회 1,551
17년 전 조회 2,085
17년 전 조회 4,775
17년 전 조회 1,459
17년 전 조회 2,188
17년 전 조회 2,166
17년 전 조회 2,437
17년 전 조회 2,186
17년 전 조회 4,470
17년 전 조회 2,969
17년 전 조회 2,912
17년 전 조회 1,637
17년 전 조회 1,285
17년 전 조회 3,989
17년 전 조회 1,654
17년 전 조회 1,652
17년 전 조회 2,153
17년 전 조회 1,926
17년 전 조회 1,539
17년 전 조회 3,957
17년 전 조회 1,791
17년 전 조회 3,170
17년 전 조회 3,040
17년 전 조회 1,078
17년 전 조회 1,887
17년 전 조회 1,635
17년 전 조회 1,887
17년 전 조회 2,677
17년 전 조회 3,067
17년 전 조회 3,258
17년 전 조회 3,365
17년 전 조회 1,505
17년 전 조회 1,455
17년 전 조회 2,292
17년 전 조회 2,019
17년 전 조회 2,324
17년 전 조회 2,852
17년 전 조회 3,300
17년 전 조회 2,401
17년 전 조회 1,671
17년 전 조회 3,247
17년 전 조회 3,111
17년 전 조회 3,085
17년 전 조회 3,955
17년 전 조회 2,632
17년 전 조회 2,446
17년 전 조회 2,690
17년 전 조회 2,930
17년 전 조회 2,650
17년 전 조회 1,492
17년 전 조회 1,933
17년 전 조회 1,524
17년 전 조회 1,949
17년 전 조회 2,553
17년 전 조회 8,734
17년 전 조회 3,194
17년 전 조회 4,285
17년 전 조회 2,021
17년 전 조회 3,704
17년 전 조회 1,597
17년 전 조회 1,420
17년 전 조회 2,361
17년 전 조회 1,351
17년 전 조회 1,675
17년 전 조회 1,506
17년 전 조회 2,568
17년 전 조회 1,537
17년 전 조회 1,132
17년 전 조회 1,261
17년 전 조회 3,146
17년 전 조회 2,191
17년 전 조회 2,005
17년 전 조회 1,257
17년 전 조회 2,482
17년 전 조회 1,205
17년 전 조회 1,172