본문 바로가기

프로그래밍/웹

로그인 폼 작성

반응형
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
72
73
74
75
76
<!doctype html>
<html lang="ko">
 <head><title> 로그인 양식</title>
<meta charset="utf-8">
<script language=javascript>    
  
       function checkID(){
       document.login_form.id.focus();
       }                  
   function login_func(){
 
       user_id  = document.login_form.id.value;
       user_pw  = document.login_form.pw.value; 
       user_pwc = document.login_form.pwcheck.value;
       user_em  = document.login_form.email.value;
       
       if (user_id == ""){
                  alert("아이디를 입력해 주세요!")
                  document.login_form.id.focus(); 
                  return false;
       } else if (user_pw == "") {
                  alert("비밀번호를 입력해 주세요!")
                  document.login_form.pw.focus(); 
                  return false;
       } else if (user_pw != user_pwc ) {
          document.login_form.pw.value="";
          document.login_form.pwcheck.value="";
                  alert("비밀번호를 다시 입력해 주세요!")
                  document.login_form.pw.focus(); 
                  return false;
       } else if (user_em.search("@"==-1 ) {
                  alert("이메일 형식이 아닙니다.");
                  document.login_form.email.value = "";
                  document.login_form.email.focus();
                  return false
       }
       
           alert("아이디 : " + user_id + "\n비밀번호 : " + user_pw + "\n이메일 : " + user_em);
         
   }
   </script>
 </head>
 <body onLoad=checkID()><center>
 
     <form name ="login_form">
         <table border=1 align=center width=300>
             <tr>
                 <th colspan="2">로그인 하기</th>
              </tr>   
              <tr>
                  <th>아이디</th>
                  <td><input type=text size=12 maxlength=12 name="id" autofocus ></td> 
              </tr>   
             <tr>
                  <th>비밀번호</th>
                  <td><input type=text size=12 maxlength=16 name="pw"></td>
             </tr> 
             <tr>
                  <th>비밀번호 확인</th>
                  <td><input type=text size=12 maxlength=16 name="pwcheck"></td>
             </tr> 
             <tr>
                  <th>이메일</th>
                  <td><input type=text size=12 maxlength=24 name="email"></td>
             </tr> 
          <tr>
              <td colspan="2"><center>
                 <input type=button value="확인" onclick="login_func()">&nbsp;
                 <input type=reset>
                 </td>
          </tr>
         </table>        
     </form>
    </center>
 </body>
</html>
cs

 

 위 코드를 html로 저장할 때 인코딩은 UTF-8로 설정한다.

반응형