前端 这样判断,有问题吗? 为什么这样不行,提示缺少对象!!!
<script language="JavaScript">
function check()
{
if (document.form1.name.value)=='')
{alert ("请输入用户名");
document.form1.name.focus();
}
else if(document.form1.name.value.length>20||document.form1.name.value.length<4)
{ alert ("用户名的长度必须在4和20个字符之间");
document.form1.name.focus();
}
else if(document.form1.password.value=='')
{ alert ("请输入密码");
document.form1.password.focus();
}
else if(document.form1.age.value=='')
{ alert ("请输入年龄");
document.form1.age.focus();
}
else if(document.form1.age.value>150||document.form1.age.value<0)
{ alert ("请输入正确的年龄");
document.form1.age.focus();
}
else if(document.form1.address.value=='')
{ alert ("请输入地址");
document.form1.address.focus();
}
else if(document.form1.wantphone.value==1 and document.form1.tel01.value=='')
{ alert ("请输入你的电话号码");
document.form1.wantphone.focus();
}
else if(document.form1.wantemail.value==1 and document.form1.email.value=='')
{ alert ("请输入你的电子邮件地址");
document.form1.email.focus();
}
else
{
document.form1.submit();
}
}
</script>
<input name="Submit" type="button" value="提交" onClick="check()">
提示错误: 缺少对象