这段JS代码在火狐中为什么不管用

xinshou_php 2010-09-16 05:48:23
 function Check(){
var reqInputs=document.getElementsByName("text_name");
for(var i=0,len=reqInputs.length;i<len;i++){
if(reqInputs[i].value.length==0){
alert("请输入指定的信息");
reqInputs[i].focus();
return false;
}
}
return true;
}



.....
<tr>
<td height="30" class="zi" ><img src="img/38.gif" width="10" height="10"/>结束时间:</td>
<td align="left" class="zhushi">
<input type="text" id="text_name" name="end" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' });">*格式:年-月-日</td>
</tr>
<tr>
<td height="30" class="wenzi"><img src="img/38.gif" width="10" height="10"/>备  注:</td>
<td align="left" class="zhushi">
<input type="text" id="text_name" name="sre" value="" >*输入中文</td>
</tr>
<tr>
<td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>s_type:</td>
<td align="left" class="zhushi"><input type="text" name="s_tp" value=""> 输入数字</td>
</tr>
<tr>
<td height="30" class="zi"><img src="img/38.gif" width="10" height="10"/>内容介绍:</td>
<td width="388"> </td>
</tr>
<tr>
<td align="left" colspan="2" class="zhushi">    
<textarea name="ctn" id="text_name" style="width:300px; height:50px;"></textarea>*输入中文
</td>
</tr>
<tr>
<td align="center" height="50" colspan="2" ><input type="image" src="img/queren.gif"></td>
</tr>
</table>
...全文
90 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jnhcd 2010-09-17
  • 打赏
  • 举报
回复
直接用firebug调试下吧。。
kala197 2010-09-17
  • 打赏
  • 举报
回复
1 看下JS函数调用了没
2 alert下值 var reqInputs=document.getElementsByName("text_name");
3 在火狐的错误控制台下查看下报错信息
贴上来
xinshou_php 2010-09-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 yuyizhao198 的回复:]
var reqInputs=document.getElementById("text_name");
[/Quote]
还是不行
yuyizhao198 2010-09-16
  • 打赏
  • 举报
回复
var reqInputs=document.getElementById("text_name");
brainwkernighan 2010-09-16
  • 打赏
  • 举报
回复
ie的bug,name和id混淆不分。所以byid也能得到。firefox则正常。
你这样写法不符合标准。
plzzz 2010-09-16
  • 打赏
  • 举报
回复
id----唯一性

你应该用 tableNode.getElementsByTagName('input')

87,917

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧