<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
window.onload=function(){
var id = document.getElementById("id");
var pass = document.getElementById("pass");
id.onkeyup=chId;
pass.onkeyup=chPass;
}
function chId(){
var key = event.keyCode;
// 숫자 48~57 키패드 96~105 알파벳 65~90
//alert(key);
if(key!=8){
if(!((48<=key&&key<=57)||(96<=key&&key<=105)||(65<=key&&key<=90))){
alert("알파벳과 숫자로만 입력가능");
this.value="";
this.focus();
return;
}
}
}
function chPass(){
var length = this.value.length;
var key = event.keyCode;
if(key==13){
if(isNaN(this.value)||(!(8<=length&&length<=12))){
alert("숫자로만 입력가능(8~12)");
this.value="";
this.focus();
return;
}
}
}
function register(){
var name = document.getElementById("name");
var hobby = document.getElementsByName("hobby");
var hobbyFlag = false;
if(id.value==""){
alert("아이디 미입력");
id.focus();
return;
}
if(pass.value==""){
alert("패스워드 미입력");
pass.focus();
return;
}
if(name.value==""){
alert("이름 미입력");
name.focus();
return;
}
for(var i=0; i<hobby.length;i++){
if(hobby[i].checked){
hobbyFlag = true;
}
}
if(!hobbyFlag){
alert("취미 미입력");
hobby[0].focus();
return;
}
alert("등록완료");
}
</script>
</head>
<body><center>
<h3>회원가입</h3>
<table>
<tr>
<td>ID</td>
<td><input type="text" id="id"/></td>
</tr>
<tr>
<td>PASS</td>
<td><input type="password" id="pass"/></td>
</tr>
<tr>
<td>이름</td>
<td><input type="text" id="name"/></td>
</tr>
<tr>
<td>취미</td>
<td>
수영<input type="checkbox" name="hobby"/>
등산<input type="checkbox" name="hobby"/>
낚시<input type="checkbox" name="hobby"/>
게임<input type="checkbox" name="hobby"/>
</td>
</tr>
<tr>
<td colspan="2"><input type="button" value="등록완료" onclick="register()"/></td>
</tr>
</table>
</body>
</html>
'IT > 기타' 카테고리의 다른 글
tomcat timeout 에러 (0) | 2015.08.19 |
---|---|
Spring Form Tag (0) | 2015.02.27 |
[Sencha Architect/ExtJS/센차] - view(뷰)만들기 (0) | 2014.07.20 |
텔넷(TELNET)을 이용한 이메일(EMAIL) 전송 (0) | 2014.07.09 |
CMOS 비밀번호 설정 & CMOS 비밀번호 해제(BIOS) - [J] (4) | 2014.07.09 |