웹프로그래밍

Global It Leader!!


jQuery


 
 

비밀번호 규칙성 체크 정규식

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 4건 조회 5,454회 작성일 12-08-21 14:54

본문

// javascript
var patt_k = /([가-힣ㄱ-ㅎㅏ-ㅣ\x20])/i; // 한글 정규식
var patt_e = /[A-z]/i; // 영문자 정규식
var patt_w = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi; // 특수문자 정규식
var patt_n = /[\d]/i; // 숫자 정규식
var patt_4num1 = /(\w)\1\1\1/; // 같은 영문자&숫자 연속 4번 정규식
var patt_4num2 = /([\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"])\1\1\1/; // 같은 특수문자 연속 4번 정규식
var patt_4num3 = /([가-힣ㄱ-ㅎㅏ-ㅣ\x20])\1\1\1/; // 같은 한글 연속 4번 정규식
var patt_cont = /(0123)|(1234)|(2345)|(3456)|(4567)|(5678)|(6789)|(7890)/; // 연속된 숫자 정규식

// php
if(preg_match("/(\w)\\1\\1\\1/", $str)) // 같은 영문자&숫자 연속 4번 정규식
if(preg_match("/([\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"])\\1\\1\\1/", $str)) // 같은 특수문자 연속 4번 정규식
if(preg_match("/([\xA1-\xFE][\xA1-\xFE])\\1\\1\\1/", $str)) // 같은 한글 연속 4번 정규식
if(preg_match("/(0123)|(1234)|(2345)|(3456)|(4567)|(5678)|(6789)|(7890)/", $str)) // 연속된 숫자 정규식

댓글목록

오원장님의 댓글

no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 작성일

//지남하 start!!!

function fnCheckPassword(uid, upw) {

    var chk_num = upw.search(/[0-9]/g);
    var chk_eng = upw.search(/[a-z]/ig);
    var strSpecial = upw.search(/[`~!@#$%^&*|\\'\";:\/?]/gi);

    var birth = document.forms[0].birth.value;
    var sub_birth = birth.substring(4,8);

    var isCapslock = false;

    //alert("주민등록번호 : "+<%=resident_id%>);  6407201234567
    <%
        String sub_resident_id = resident_id.substring(7,13);
    %>
    var strResident_id = "<%=sub_resident_id%>";

    alert("web_id =>"+document.forms[0].web_id.value +'\n\n'+"web_pwd =>"+document.forms[0].web_pwd.value);
    //alert("birth =>"+document.forms[0].birth.value);
    alert("sub_birth =>"+sub_birth);   
    //alert("strResident_id =>"+strResident_id);

    if( upw.indexOf( uid ) > -1) {
        alert("비밀번호에 ID를 포함할수 없습니다.");
        return false;
    }

    /* check whether input value is included space or not  */
    var retVal = checkSpace( upw );
    if( retVal ) {
        alert("비밀번호는 공백없이 입력해 주세요.");
        return false;
    }

    if( upw.indexOf( strResident_id ) > -1){
        alert("비밀번호에 주민등록번호를 포함할수 없습니다.");
        return false;
    }
   
    if( upw.indexOf( document.forms[0].birth.value ) > -1 || upw.indexOf( sub_birth ) > -1){
        alert("비밀번호에 생년월일을 포함할수 없습니다.");
        return false;
    }

    if( upw.indexOf( document.forms[0].cellphone_3.value ) > -1){
        alert("비밀번호에 휴대폰을 포함할수 없습니다.");
        return false;
    }

    if( upw.indexOf( document.forms[0].homephone_3.value ) > -1){
        alert("비밀번호에 자택 연락처를 포함할수 없습니다.");
        return false;
    }

    if(upw.search(uid)>-1){
        alert("ID가 포함된 비밀번호는 사용하실 수 없습니다.");
        return false;
    }

    if(upw.length < 8){
        alert("8자 이상의 비밀번호만 입력 가능 합니다.");
        return false;
    }

    if(upw.length > 12){
      alert("12자 이하의 비밀번호만 입력 가능 합니다.");
      return false;
    }

    if(upw.length < 8 || upw.length > 12){
      alert("비밀번호를 8자리 이상 12자리 이하로 입력 가능 합니다.");
      return false;
    }

    if(chk_num < 0 || chk_eng < 0 || strSpecial < 0){
      alert('비밀번호는 문자,숫자,특수문자가 조합 되어야 합니다.');
      return false;
    }

    return true;
}

// space 가 있으면 true, 없으면 false
function checkSpace( str )
{
    if(str.search(/\s/) != -1){
      return true;
    } else {
        return false;
    }
}

//지남하 end!!!

오원장님의 댓글

no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 작성일

/* 비밀번호 확인
* 사용법 : */
function fnCheckPassword(uid, upw)

{
    if(!/^[a-zA-Z0-9]{8,20}$/.test(upw))

    {
        alert!('비밀번호는 숫자와 영문자 조합으로 8~20자리를 사용해야 합니다.');
        return false;
    }

 
    var chk_num = upw.search(/[0-9]/g);
    var chk_eng = upw.search(/[a-z]/ig);

    if(chk_num < 0 || chk_eng < 0)

    {
        alert!('비밀번호는 숫자와 영문자를 혼용하여야 합니다.');
        return false;
    }
   
    if(/(\w)\1\1\1/.test(upw))

    {
        alert!('비밀번호에 같은 문자를 4번 이상 사용하실 수 없습니다.');
        return false;
    }

    if(upw.search(uid)>-1)

    {
        alert!('ID가 포함된 비밀번호는 사용하실 수 없습니다.');
        return false;
    }


    return true;

}

전체 142
게시물 검색
jQuery 목록
번호 제목 글쓴이 조회 날짜
102 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4998 07-11
101 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3458 06-24
100 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3567 12-22
99 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3753 08-13
98 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3683 08-04
97 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3865 07-17
96 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7257 06-16
95 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3542 06-04
94 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4352 05-20
93 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 4587 05-20
92 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3268 05-13
91 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3396 05-12
90 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3333 05-12
89 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3290 05-01
88 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3176 04-23
87 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3316 04-17
86 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3276 02-03
85 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3248 01-12
84 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3259 04-04
83 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 3713 01-30