首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

<form></form>onsubmit 的有关问题

2013-07-27 
form/formonsubmit 的问题script srcjs/1.js typetext/javascript/script。。。。省略部分代码

<form></form>onsubmit 的问题


<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>

1.js
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;
}
}


为什么checknews() 点击提交就成功呢?帮忙提示下
[解决办法]
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
------解决方案--------------------


nauthor==""){
alter("请输入作者");
return false;
}
else if(nsummary==null
[解决办法]
nsummary==""){
alter("请输入摘要");
return false;
}
else if(ncontent==null
[解决办法]
ncontent==""){
alter("请选择内容");
return false;
}
        else{
                return true;
        }
        return false;
}


[解决办法]
.value

热点排行