<script>
function chk()
{
var a=new Object();for(i=1;i<=4;i++)
{
a[i]='text'+i;
if (document.all[a[i]].value=="")
alert(i+'为空');
}
}
</script>
<body>
<input name=text1>
<input name=text2>
<input name=text3>
<input name=text4>
<input type=button value="chk" onclick="chk()">
</body>
function chk()
{
var a=new Object();for(i=1;i<=4;i++)
{
a[i]='text'+i;
if (document.all[a[i]].value=="")
alert(i+'为空');
}
}
</script>
<body>
<input name=text1>
<input name=text2>
<input name=text3>
<input name=text4>
<input type=button value="chk" onclick="chk()">
</body>
function check()
{
for(i=1;i<11;i++)
{
test="test"+i
if(document.forms[0].all[test].value=="")
{
alert("表单不能为空");
return false;
}
else
{
document.forms[0].submit();
}
}
}</script>
<form action="check.asp">
<script>
for(i=1;i<11;i++)
{
document.write("<input name='test"+i+"'><br>")
}
</script>
<input type="button" onclick="check()" value="提交">
</form>
<head>
<script language="javascript">
function doSubmit(form){
var Elements = form.elements;
for (var i = 0; i < Elements.length; i++){
if (Elements[i].tagName == "INPUT"&&Elements[i].type=="text"&&Elements[i].value=="") {
alert("存在空");
return;
}
}
}</script>
<form name="DATAFORM">
<input type="text" >
<input type="text" >
<input type="text" >
<input type="text" >
<input type="text" >
<input type="text" >
<input type="text" >
<input type="button" value="111" onclick="doSubmit(DATAFORM)">
</FORM>
</body>
</html>