日期:2014-05-18 浏览次数:20908 次
<%
request.setCharacterEncoding("GBK");
String action = request.getParameter("action");//接收下面的form提交的action
response.sendRedirect("article.jsp");
%>
//下面是javascript代码
<script language="JavaScript1.2" type="text/javascript">
<!--
function isEmpty()
{
var title = document.postForm.title.value;
var cont = document.postForm.cont.value;
if(title=="")
{
alert("主题不能为空!!");
return false;
}
if(title!="" && cont!="")
{
alert("提交成功");
return true;
}
}
//-->
</script>
//下面是form中的代码
<form name="postForm" action="post.jsp" method="post" onsubmit="return isEmpty()">
//post.jsp是本身,就是form表单提交给本身
<input type="hidden" name="action" value="post">
<table align="center" border="1" width="100%">
<tr>
<td>
<input type="text" name="title"/>
</td>
</tr>
<tr>
<td>
<textarea rows="15" cols="150" name="cont"> </textarea&g