增加界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>发布新闻</title>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">发布新闻</h1>
<a href="Screen.jsp">返回主页</a>
<form name="form1" action="Servlet?method=add" method="post" onsubmit="return check()">
<div class="a">
新闻标题<input type="text" id="zhuti" name="zhuti" />
</div>
<div class="a">
新闻关键字<input type="text" id="mudi" name="mudi" />
</div>
<div class="a">
新闻撰稿人<input type="text" id="huodongleixing" name="huodongleixing" />
</div>
<div class="a">
新闻日期<input type="text" id="time" name="time" />
</div>
<div class="a">
新闻地点<input type="text" id="didian" name="didian" />
</div>
<div class="a">
新闻内容<input type="text" id="neirong" name="neirong" />
</div>
<div class="a">
<button type="submit" class="b">保 存</button>
<input type="reset" value="重置" />
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var zhuti = document.getElementById("zhuti");
var mudi = document.getElementById("mudi");
// var huodongleixing = document.getElementById("huodongleixing");
var time = document.getElementById("time");
var didian = document.getElementById("didian");
//var duixiang = document.getElementById("duixiang1")+document.getElementById("duixiang2");
var neirong = document.getElementById("neirong");
var richenganpai = document.getElementById("richenganpai");
if(zhuti.value == '') {
alert('活动主题为空');
zhuti.focus();
return false;
}else if(zhuti.value.length>20){
alert('活动主题内容超过字数限制');
zhuti.focus();
return false;
}
if (mudi.value == '') {
alert('活动目的为空');
mudi.focus();
return false;
}else if(mudi.value.length>50){
alert('活动目的内容超过字数限制');
mudi.focus();
return false;
}
//if (huodongleixing.value == '') {
// alert('活动类型为空');
// huodongleixing.focus();
// return false;
//}
if(time.value == '') {
alert('时间为空');
time.focus();
return false;
}
if (didian.value == '') {
alert('无地点');
didian.focus();
return false;
}
//if (duixiang.value == '') {
// alert('无活动对象');
// duixiang.focus();
// return false;
//}
if (neirong.value == '') {
alert('无活动内容');
neirong.focus();
return false;
}else if(neirong.value.length>500){
alert('活动内容超过字数限制');
neirong.focus();
return false;
}
if(richenganpai.value == '')
{
alert('无日程安排');
richenganpai.focus();
return false;
}else if(richenganpai.value.length>500){
alert('日程安排内容超过字数限制');
richenganpai.focus();
return false;
}
}
</script>
</body>
</html>
删除界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>删除新闻</title>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">删除新闻</h1>
<a href="Screen.jsp">返回主页</a>
<form action="Servlet?method=getbyname" method="post" onsubmit="return check()">
<div class="a">
新闻标题<input type="text" id="zhuti" name="zhuti"/>
</div>
<div class="a">
<button type="submit" class="b">删 除</button>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var zhuti = document.getElementById("zhuti");
//非空
if(name.value == '') {
alert('户主名为空');
name.focus();
return false;
}
}
</script>
</body>
</html>
查询界面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询新闻</title>
</head>
<body>
<%
Object message = request.getAttribute("message");
if(message!=null && !"".equals(message)){
%>
<script type="text/javascript">
alert("<%=request.getAttribute("message")%>");
</script>
<%} %>
<div align="center">
<h1 style="color: black;">查询新闻</h1>
<a href="Screen.jsp">返回主页</a>
<form action="Servlet?method=getbyname" method="post" onsubmit="return check()">
<div class="a">
新闻标题<input type="text" id="zhuti" name="zhuti"/>
</div>
<div class="a">
<a href="del2.jsp"><font size=3>查 询</font></a>
</div>
</form>
</div>
<script type="text/javascript">
function check() {
var zhuti = document.getElementById("zhuti");
//非空
if(name.value == '') {
alert('户主名为空');
name.focus();
return false;
}
}
</script>
</body>
</html>
标签:13,return,focus,value,alert,测试,false,课堂,message From: https://www.cnblogs.com/ysl666/p/17117559.html