簡單學生選課系統之登入介面
阿新 • • 發佈:2019-01-08
圖片
程式碼:
checkcode.jsp
test.jsvar code ; //在全域性定義驗證碼 //產生驗證碼 function createCode(){ code = ""; var codeLength = 4;//驗證碼的長度 var checkCode = document.getElementById("checkCode"); var random = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R', 'S','T','U','V','W','X','Y','Z');//隨機數 for(var i = 0; i < codeLength; i++) {//迴圈操作 var index = Math.floor(Math.random()*36);//取得隨機數的索引(0~35) code += random[index];//根據索引取得隨機數加到code上 //把code值賦給驗證碼 if (checkCode) { checkCode.className = "code"; checkCode.value = code; checkCode.blur(); } } } function validate(){ var inputCode = document.getElementById("test").value; if (inputCode.length <= 0) { alert("請輸入驗證碼!"); return false; } else if (inputCode.toUpperCase() != code) { alert("驗證碼輸入錯誤!"); createCode();// 重新整理驗證碼 return false; } register.submit(); }
date.jsfunction check(register){ var no=register.studentno.value; var pass=register.password.value; var tests=register.test.value; if(no==""){ alert("學號不能為空!"); register.studentno.focus(); register.studentno.select(); } else if(pass==""){ alert("密碼不能為空!"); register.password.focus(); register.password.select(); } else if(tests==""){ alert("驗證碼不能為空!"); register.test.focus(); register.test.select(); } else if(type==""){ alert("型別不能為空!"); } return true; }
firstpage.jspvar time,year,month,day,hour,minute,second; var today=new Date(); month=today.getMonth()+1; day=today.getDay(); var s=today.getFullYear()+"年"+month+"月"+today.getDate()+"日"+today.getHours()+"時"+today.getMinutes()+"分"+today.getSeconds()+"秒"+"\t"; document.write(s); switch(day){ case 1:document.write("星期一");break; case 2:document.write("星期二");break; case 3:document.write("星期三");break; case 4:document.write("星期四");break; case 5:document.write("星期五");break; case 6:document.write("星期六");break; case 7:document.write("星期日");break; }
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>學生選課系統</title>
<style type="text/css">
body{margin:0}
.whole{
width:1520px;
height:800px;
background:url(timg.jpg);
}
.head{
height:300px;
width:1520px;
}
.lhead{
float:right;
}
.main{
width:1520px;
height:500px;
}
</style>
<script type="text/javascript" src="checkcode.js"></script>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<div class="whole">
<div class="head">
<div class="lhead">
<script type="text/javascript" src="date.js"></script>
</div>
<h style="font-size:60px;color:#ffff00"><marquee behavior="alternate";scrolldelay="10";>歡迎進入選課系統</marquee></h>
</div>
<div class="main">
<center>
<form action="dofirstpage.jsp" name="register" method="post" onClick="return check(this)">
學 號:<input type="text" name="studentno" value=""><br>
密 碼:<input type="password" name="password" value=""><br>
驗證碼:<input type="text" id="test" style="width:90px">
<input type="text" onClick="createCode();" readonly="readonly" id="checkCode" class="unchanged" style="width: 56px;cursor:pointer" />
<br>
類 型:
<input type="radio" name="types" value="學生">學生
<input type="radio" name="types" value="管理員">管理員<br>
<input type="submit" value="登入" onClick="validate();">
<input type="reset" value="重置">
</form>
</center>
</div>
</div>
</body>
</html>