登录页面js提示输入代码

 1 <html>
 2   <head>
 3     
 4     <title>My JSP 'login.jsp' starting page</title>
 5     <script language="javascript">
 6         function check(){
 7             var name = form1.Username.value;
 8             var pwd = form1.Password.value;
 9             var tp = form1.Type.value;
10             if(tp == ""){
11                  alert("请选择身份!");
12                  form1.Type.focus(); 
13                  return;
14             }else if((name=="") || (name == null)){
15                 alert("请输入帐号");
16                 form1.user.focus();
17                 return;    
18             }else if((pwd == "") || (pwd == null)){
19                 alert("请输入密码");
20                 form1.pwd.focus();
21                 return;
22             }else{
23                 form1.submit();
24             }
25         }
26     </script>
27     </head>
28   
29   <body>
30     <form name="form1" method="post" action="GoLogin.action">
31         <table width="300" border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="0" 
32                 bordercolordark="#cccccc" bordercolorlight="#FFFFF">
33             <tr>
34                 <td height="30" colspan="2" bgcolor="#eeeeee">用户登录</td>
35             </tr>
36             <tr>
37                 <td width="70" height="30">身份:</td>
38                 <td>
39                   <select name="Type"> 
40                     <option value="">请选择</option>
41                     <option value="系统管理员">系统管理员</option>
42                     <option value="楼宇管理员">楼宇管理员</option>
43                     <option value="学生">学生</option>
44                   </select>
45               </td>
46             </tr>
47             <tr>
48                 <td width="70" height="30">帐号:</td>
49                 <td width="162"><input name="Username" type="text" id="userName"/></td>
50             </tr>
51             <tr>
52                 <td height="30">密&nbsp;;&nbsp;码:</td>
53                 <td><input name="Password" type="text" id="userPwd" /></td>
54             </tr>
55             <tr>
56                 <td height="30" colspan="2" align="center">
57                     <input type="button" value="登录" onclick="return check()" />
58                     <input type="reset" value="重置" />
59                     
60                 </td>
61             </tr>
62         </table>
63     </form>
64   </body>
65 </html>

 

posted @ 2017-07-11 08:43  XuGuobao  阅读(766)  评论(0编辑  收藏  举报