Jsp - 회원가입창

2020. 6. 16. 11:35Jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
 
function fun1() {
    if(document.fr.text.value.length==0){
        
        alert("텍스트입력하세요");
        document.fr.text.focus();
        return;
    }
    if(document.fr.pass.value.length==0){
        alert("비밀번호입력하세요");
        document.fr.pass.focus();
        return;
 
    }
    if(document.fr.tx.value.length==0){
        alert("긴텍스트 입력하세요");
        document.fr.tx.focus();
        return;
    }
    if(document.fr.ra[0].checked==false && document.fr.ra[1].checked==false){
        alert("라디오를 선택하세요");
        document.fr.ra[0].focus();
        return;
    }
    if(document.fr.ch[0].checked==false&&document.fr.ch[1].checked==false&&document.fr.ch[2].checked==false){
        
        alert("체크박스를 선택하세요");
        document.fr.ch[0].focus();
        return;
    }
    if(document.fr.sel[0].selected==true){
        
        alert("목록상자를 선택하세요");
        document.fr.sel.focus();
        return;
    }
    document.fr.submit();
}
 
 
</script>
</head>
<body>
<h1>js3/test6.html</h1>
<form action="a.jsp" method="post" name="fr"> 
텍스트 : <input type="text" name="text"><br>
비밀번호 : <input type="password" name="pass"><br>
긴텍스트 : <textarea name="tx" rows="10" cols="20"></textarea><br>
라디오 : <input type="radio" name="ra" value="ra1">라디오1
             <input type="radio" name="ra" value="ra2">라디오2<br>
체크박스 : <input type="checkbox" name="ch" value="ch1">체크1
                 <input type="checkbox" name="ch" value="ch2">체크2
                 <input type="checkbox" name="ch" value="ch3">체크3<br>
<!--                 <select name="sel" multiple="multiple" size="3"></select> -->
목록상자 :<select name="sel">
<option value="">선택하세요</option>
<option value="sel1">선택1</option>
<option value="sel2">선택2</option>
<option value="sel3">선택3</option>
</select><br>
<input type="button" value="회원가입체크" onclick="fun1()">
 
</form>
</body>
</html>
cs

 

 

회원가입 체크 버튼 클릭했을 때 체크가 되어있지 않은 타입들이 있으면 메시지를 띄우고 순서대로 포커스를

맞추는 작업을 해보았다. 갈수록 복잡해질수록 재밌어 지고 있다.

'Jsp' 카테고리의 다른 글

Jsp - request,response  (0) 2020.06.27
Jsp - 회원가입전송  (0) 2020.06.17
Jsp - 버튼제어3  (0) 2020.06.16
Jsp - 버튼제어2  (0) 2020.06.16
Jsp - 버튼제어  (0) 2020.06.16