我想检查以下代码是否将表单字段留空:
<script>
function validateForm()
{
var x=document.forms["myForm"]["name"].value;
if (x==null || x=="")
{
alert(" Name Required* ");
return false;
}
}
</script>
<form action="register2.php" method="POST" id="myForm" onsubmit="return validateForm()" >
<input type="text" name="name"/>
</form>
但它只检查输入框,我如何检查选择框、单选按钮和复选框?