<input maxlength=25 id=1 size=25 name=username1>
<input maxlength=25 id=2 size=25 name=username2>
<input maxlength=25 id=3 size=25 name=username3>
<input maxlength=25 id=4 size=25 name=username4>
......
for (i=1;i<100;i++){
if(i.value==""){
alert("请完整填写信息!");
i.focus()
return false;
}
}
<input maxlength=25 id=2 size=25 name=username2>
<input maxlength=25 id=3 size=25 name=username3>
<input maxlength=25 id=4 size=25 name=username4>
......
for (i=1;i<100;i++){
if(i.value==""){
alert("请完整填写信息!");
i.focus()
return false;
}
}
<input maxlength=25 size=25 name=username1>
<input maxlength=25 size=25 name=username2>
<input type=button onclick="checkform()">
</form>
<script>
function check(obj,msg)
{
var boo;
boo=true;
if(document.form1[obj].value=="")
{
document.form1[obj].focus();
boo=false;
alert(msg);
}
return boo;
}
function checkform()
{
if(check('username1','请输入用户名')&&check('username2','请输入密码'))form1.submit();
}
</script>检测多个输入框
if(check('textname1','警告内容1')&&check('textname2','警告内容2')&&check('textname3','警告内容3'))form1.submit()