日期:2014-05-17 浏览次数:20873 次
<script src="js/1.js" type="text/javascript"></script>
。。。。省略部分代码
<form action="success.jsp" method="post" name="myform" onsubmit ="return checknews();" >
<table>
<tr>
<td> <input type="submit" value="提交" /></td>
<td ><input type="reset" value="重置"/></td>
</tr>
</table>
</form>
function checknews(){
var ntopic=document.getElementsByName("topic");
var ntitle=document.getElementsByName("title");
var nauthor=document.getElementsByName("author");
var nsummary=document.getElementsByName("summary");
var ncontent=document.getElementsByName("content");
if(ntopic==null||ntopic==""){
alter("请选择主题");
return false;
}
if(ntitle==null||ntitle==""){
alter("请输入标题");
return false;
}
if(nauthor==null||nauthor==""){
alter("请输入作者");
return false;
}
if(nsummary==null||nsummary==""){
alter("请输入摘要");
return false;
}
if(ncontent==null||ncontent==""){
alter("请选择内容");
return false;
}
}
function checknews(){
var ntopic=document.getElementsByName("topic");
var ntitle=document.getElementsByName("title");
var nauthor=document.getElementsByName("author");
var nsummary=document.getElementsByName("summary");
var ncontent=document.getElementsByName("content");
if(ntopic==null
------解决方案--------------------
ntopic==""){
alter("请选择主题");
return false;
}
else if(ntitle==null
------解决方案--------------------
ntitle==""){
alter("请输入标题");
return false;
}
else if(nauthor==null
------解决方案--------------------