javascript 判断控件名为数字,且重复的值不充许为空 哪位大哥可以帮帮忙
<html>
<head>
<SCRIPT language=javascript>
<!--
function check()
{
if (from1.1.value== " ")
{
window.alert( "请输入用户名! ");
return false;
}
else if (from1.1.value== " ")
{
window.alert( "请输入电话号码! ");
return false;
}
else{
return true;
}
}
-->
</script>
</head>
<body>
<FORM name= "form1 " action= " " method=post onSubmit= "return check() ">
<INPUT name=member type=hidden value=> <INPUT name=.state type=hidden value=1>
<TR> </FONT> 用户名 </FONT> : </TD> <TD> <INPUT class= "style1 " maxLength=9 name=1 size=20 typt= "text "> </TD> </TR> </TD> </TR>
<INPUT class= "style1 " maxlength=16 name=1 type=hidden typt= "text " value= "---- ">
<TR> <FONT size=2> 电话号码 </FONT> : </TD> <TD width=417> <INPUT class= "style1 " size=21 maxlength=16 name=1 type= "text " typt= "text "> <FONT color=#ff0000> </FONT> </TD> </TR>
<INPUT class= "style1 " maxlength=16 name=1 type=hidden typt= "text " value= "---- ">
<TR>
<td height=25 width=> </td>
<td height=25 width= align= "right ">
<INPUT type=submit value=提交申请>
<INPUT type=reset value=重新填写> </td>
</table>
</body>
</html>
------解决方案--------------------e = document.form1.elements
for(i = 0;i <e.length;i++)
{
if(e[i].value== " ") alert( "错误 ")
}
另外,不推荐使用数字做id或者name
------解决方案--------------------var objs=document.getElementsByName( "hym ")
for(var i=0;i <objs.length;i++)
{
alert(objs[i].value)
}