我的这个页面的请空检查为什么不起作用啊。<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.util.*,java.sql.*,myweb.*" errorPage="../error.jsp"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>testnews</title>
<script type="text/javascript">
function submit(){
if(document.all.title.value.length==0){
alert("请填写新闻标题!");
return false;
}
if(document.all.source.value.length==0){
alert("请填写新闻来源!");
return false;
}
if(document.all.content.value.length==0){
alert("请填写新闻内容!");
return false;
}
return true;
}
</script>
</head>
<body>
This is my JSP page. <br>
<jsp:useBean id="newsp" class="myweb.newsprocess" scope="page"/>
<%Collection temp=newsp.SelcetNewsAll();
Iterator it=temp.iterator();
while(it.hasNext()){
news news=(news)it.next(); %>
<%=news.getNewsId() %>,<%=news.getTitle() %>,<%=news.getSource() %>,<%=news.getTime() %>,<%=news.getContent() %><br/>
<%} %>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#000099">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#FFFFFF"> <b>*</b> </td>
<td width="100%"><font color="#CCCCCC"> <font color="#FFFFFF">添加新闻测试</font></font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="100%" bgcolor="#EAEAEA" colspan="2"> <form name="submitnews" action="testnews1.jsp" method="post">
<p><label for="textfield">新闻标题</label><br><input type="text" name="title" id="title" size="40"></p>
<p><label for="textfield2">新闻来源</label><br><input type="text" name="source" id="source" size="40"></p>
<p><label for="textfield2">新闻内容</label><br><input type="text" name="content" id="source" value="" size="100" maxlength="2000"></p>
<p><input type="submit" name="Submit" value="OK" onClick="submit()"></p>
</form>
</td>
</tr></table>
</body>
</html>
<html>
<head> <title>testnews</title>
<script type="text/javascript">
function submit(){
if(document.all.title.value.length==0){
alert("请填写新闻标题!");
return false;
}
if(document.all.source.value.length==0){
alert("请填写新闻来源!");
return false;
}
if(document.all.content.value.length==0){
alert("请填写新闻内容!");
return false;
}
return true;
}
</script>
</head>
<body>
This is my JSP page. <br>
<jsp:useBean id="newsp" class="myweb.newsprocess" scope="page"/>
<%Collection temp=newsp.SelcetNewsAll();
Iterator it=temp.iterator();
while(it.hasNext()){
news news=(news)it.next(); %>
<%=news.getNewsId() %>,<%=news.getTitle() %>,<%=news.getSource() %>,<%=news.getTime() %>,<%=news.getContent() %><br/>
<%} %>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#000099">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td bgcolor="#FFFFFF"> <b>*</b> </td>
<td width="100%"><font color="#CCCCCC"> <font color="#FFFFFF">添加新闻测试</font></font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="100%" bgcolor="#EAEAEA" colspan="2"> <form name="submitnews" action="testnews1.jsp" method="post">
<p><label for="textfield">新闻标题</label><br><input type="text" name="title" id="title" size="40"></p>
<p><label for="textfield2">新闻来源</label><br><input type="text" name="source" id="source" size="40"></p>
<p><label for="textfield2">新闻内容</label><br><input type="text" name="content" id="source" value="" size="100" maxlength="2000"></p>
<p><input type="submit" name="Submit" value="OK" onClick="submit()"></p>
</form>
</td>
</tr></table>
</body>
</html>
解决方案 »
- 频繁刷新页面数据库报错
- jsp分页技术我的怎么老是显示那个页面,有多少数据就显示多少数据!!!
- 关于在action中获取表单数据后是否判空,在action中的一个execute()方法中是否将所有代码放入同一个try块中
- spring怎么和EL自定义函数搞在一起了
- js 如何判断 activex 更新
- 请问,谁知道关于JAVA制图的东西吗??????????????
- tomcat在myeclipse下用配置环境变量吗
- 请高手指点一下(在线等待)
- 怎样实现用Servlet从web下载文件到客户端?
- struts2 标签 property 如何直接输出HTML元素
- 为什么用cfx做webservice时,参数名不会显示在wsdl中, 只显示"<soap:body use="literal"/>"
- cookie自动登陆怎么做
换一个函数名,submit_1() submit_2() checkData()
不要用submit
尽量起一些自定义的名字。 不要用 submit check validate ==
在form标签里面加上onsubmit="return check();" 这句就够了