Try:
<html>
<head>
<script language=javascript>
function mm()
{
var coll = document.all.tags("INPUT");
//因为coll集合包含下面<input type=button ..>一项
//所以下面 i < coll.length-1 而不是i < coll.length
for(var i = 0; i < coll.length-1; i++)
{
if(coll[i].value == "")
alert(i + 1 +"不能为空!");
else
document.form1.submit();
}
}
</script>
</head>
<body>
<form name=form1 method=post action="aaa.asp">
1:<input type=text><br>
2:<input type=text><br>
3:<input type=text><br>
4:<input type=text><br>
5:<input type=text><br>
<input type=button onclick='mm()' value="Click me to submit">
</form>
</body>
</html>
<html>
<head>
<script language=javascript>
function mm()
{
var coll = document.all.tags("INPUT");
//因为coll集合包含下面<input type=button ..>一项
//所以下面 i < coll.length-1 而不是i < coll.length
for(var i = 0; i < coll.length-1; i++)
{
if(coll[i].value == "")
alert(i + 1 +"不能为空!");
else
document.form1.submit();
}
}
</script>
</head>
<body>
<form name=form1 method=post action="aaa.asp">
1:<input type=text><br>
2:<input type=text><br>
3:<input type=text><br>
4:<input type=text><br>
5:<input type=text><br>
<input type=button onclick='mm()' value="Click me to submit">
</form>
</body>
</html>
1.合法性验证在blur时(或之前)验证
2.必须输入验证在submit时验证(需要必须输入验证的话,在本input或select里加一代码alt="没有输入时的警告信息")