在循环中出现了多次,请问对它的值如何进行检查?

jackylinjg 2001-07-20 01:17:24
<input type="text" name="find">在循环中出现了多次,请问对它的值如何进行检查?

<input type="text" name="find">
<input type="text" name="find">
<input type="text" name="find">
请问如何对它们的输入进行合法性检查?


...全文
61 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
smalle 2001-07-20
  • 打赏
  • 举报
回复
凡是名字重复的系统就自动生成数组,可以这样访问
for(i=0;i<document.forms[0].find.length;i++)
{

}
孟子E章 2001-07-20
  • 打赏
  • 举报
回复
例子:
<form name=mxh>
<input type="text" name="find">
<input type="text" name="find" value="qq">
<input type="text" name="find">
<input type=button onclick='checkit()' value="检查"
</form>
<script>
function checkit(){
for(var i=0;i<document.mxh.elements.length;i++){
if(document.mxh.elements[i].value=="qq"){
alert("不能为qq做值")
document.mxh.elements[i].select()
}
}
}
</script>
孟子E章 2001-07-20
  • 打赏
  • 举报
回复
用form.elements[i].value

87,904

社区成员

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

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