我正在开发一个使用 php 和 mysql 的应用程序。我编写了一个用于表单验证的 javascript 代码,但它可以工作。
function checkForm()
{ if(document.Form1.Gestational_age.value=="")
{
alert('Please select an option for Gestational age in weeks ') ;
return false;
}
else if(document.Form1.PRBC.value=="")
{
alert('Please select an option for PRBC transfusion ');
return false;
}
else if(document.Form1.milk_feeding.value=="")
{
alert('Please select an option for Human milk feeding at both day 7 and day 14 of life');
return false;
}
}
</script>
<title>GutCheckNEC for infants < 1500 grams at birth Gephart,2012</title>
</head>
<body>
<div><b>GutCheckNEC for infants < 1500 grams at birth Gephart, 2012</b></div>
<br>
<form name="Form1" method="post" action ="Form1.php" onSubmit="return checkForm();">
1.   Gestational age in weeks  
<input type="radio" id="Gestational_age" name="Gestational_age" value="0-27"/>0-27
<input type="radio" name="Gestational_age" value="28-31"/>28-31
<input type="radio" name="Gestational_age" value=">32" />32
<br>
2.   PRBC transfusion  
<input type="radio" id="PRBC" name="PRBC" value="Yes"/>Yes
<input type="radio" name="PRBC" value="No"/>No
<br>
3.   Human milk feeding at both day 7 and day 14 of life  
<input type="radio" id="milk_feeding" name="milk_feeding" value="Yes"/>Yes
<input type="radio" name="milk_feeding" value="No"/>No
<br>
<input type="submit" name="submit" value="Next"/>
</form>
</body>
</html>
这是我的代码示例。请你帮忙,为什么我的 javascript 部分不起作用..