제목 : 회원등록시 아이디에 특수문자차단(스크립트)
회원등록폼을 html파일로 작성하여 아래의 스크립트를 <head>~~</head>에 삽입하세요. 그리고 아이디의 <input type=text name=input_id>에맞도록 아래의 문자열을 찾아 name값을 변경하세요.(input_id)부분...
if (!check_al_num(input_id.value))
미리보기는 위의 링크를 참고하세요..
//이아래부터복사
<script language="javascript"> <!-- function check_al_num(str) { var x = str; for(i=0 ; i< x.length; i++) { if(!IsAlpha(x.charAt(i))) return false; } return true; }
function IsAlpha(c) { if (c >= "ㄱ" && c <= "ㄱ") return 0; if (c >= "ㄴ" && c <= "ㄴ") return 0; if (c >= "ㄷ" && c <= "ㄷ") return 0; if (c >= "ㄹ" && c <= "ㄹ") return 0; if (c >= "ㅁ" && c <= "ㅁ") return 0; if (c >= "ㅂ" && c <= "ㅂ") return 0; if (c >= "ㅅ" && c <= "ㅅ") return 0; if (c >= "ㅇ" && c <= "ㅇ") return 0; if (c >= "ㅈ" && c <= "ㅈ") return 0; if (c >= "ㅊ" && c <= "ㅊ") return 0; if (c >= "ㅋ" && c <= "ㅋ") return 0; if (c >= "ㅌ" && c <= "ㅌ") return 0; if (c >= "ㅍ" && c <= "ㅍ") return 0; if (c >= "ㅎ" && c <= "ㅎ") return 0; if (c >= "ㅏ" && c <= "ㅏ") return 0; if (c >= "ㅔ" && c <= "ㅔ") return 0; if (c >= "ㅣ" && c <= "ㅣ") return 0; if (c >= "ㅗ" && c <= "ㅗ") return 0; if (c >= "ㅜ" && c <= "ㅜ") return 0; if (c >= "ㅐ" && c <= "ㅐ") return 0; if (c >= "ㅛ" && c <= "ㅛ") return 0; if (c >= "ㅕ" && c <= "ㅕ") return 0; if (c >= "ㅑ" && c <= "ㅑ") return 0; if (c >= "ㅔ" && c <= "ㅔ") return 0; if (c >= "ㅒ" && c <= "ㅒ") return 0; if (c >= "ㅖ" && c <= "ㅖ") return 0; if (c >= "·" && c <= "·") return 0; if (c >= "." && c <= ".") return 0; if (c >= "´" && c <= "´") return 0; if (c >= "'" && c <= "'") return 0; if (c >= "," && c <= ",") return 0; if (c >= ":" && c <= ":") return 0; if (c >= ";" && c <= ";") return 0; if (c >= "?" && c <= "?") return 0; if (c >= "!" && c <= "!") return 0; if (c >= "`" && c <= "`") return 0; if (c >= "、" && c <= "、") return 0; if (c >= "。" && c <= "。") return 0; if (c >= "·" && c <= "·") return 0; if (c >= " " && c <= " ") return 0; if (c >= "〃" && c <= "〃") return 0; if (c >= "‥" && c <= "‥") return 0; if (c >= "…" && c <= "…") return 0; if (c >= "¨" && c <= "¨") return 0; if (c >= "―" && c <= "―") return 0; if (c >= "˝" && c <= "˝") return 0; if (c >= "˚" && c <= "˚") return 0; if (c >= "˙" && c <= "˙") return 0; if (c >= "¸" && c <= "¸") return 0; if (c >= "˛" && c <= "˛") return 0; if (c >= "∼" && c <= "∼") return 0; if (c >= "/" && c <= "/") return 0; if (c >= "~" && c <= "~") return 0; if (c >= "\" && c <= "\") return 0; if (c >= "¡" && c <= "¡") return 0; if (c >= "ː" && c <= "ː") return 0; if (c >= "ㆍ" && c <= "ㆍ") return 0; if (c >= "┌" && c <= "┌") return 0; if (c >= "┐" && c <= "┐") return 0; if (c >= "凸" && c <= "凸") return 0; if (c >= "∥" && c <= "∥") return 0; if (c >= "@" && c <= "@") return 0; if (c >= "$" && c <= "$") return 0; if (c >= "%" && c <= "%") return 0; if (c >= "#" && c <= "#") return 0; if (c >= "`" && c <= "`") return 0; if (c >= "~" && c <= "~") return 0; if (c >= "*" && c <= "*") return 0; if (c >= "(" && c <= "(") return 0; if (c >= ")" && c <= ")") return 0; if (c >= "-" && c <= "-") return 0; if (c >= "'" && c <= "'") return 0; if (c >= "," && c <= ",") return 0; if (c >= "." && c <= ".") return 0; if (c >= "!" && c <= "!" ) return 0; if (c >= "^" && c <= "^" ) return 0; else return 1;
}
function check_id() { with(document.MemberReg) { if (!check_al_num(input_id.value)) //검사받을 폼값지정(input_id) { alert("아이디에 특수 문자나 \n\n그리고... 완성되지 않은 한글조합이 있는것 같습니다.\n\n다시 한번 확인 하세요.!"); return false; } } } //--> </script>
|