<script type="text/javascript">
//<![CDATA[
function verifyForm()
{
if( document.forms[0].age.value < 18 || >30)
{
alert(" The age input is not valid.");
return false;
}
alert("Form is valid");
return true;
}
//]]>
</script>
</head>
<body>
Enter the following information. Fields denoted with a * are required.
<form action="" method="post" name="aform">
<table>
<tr><td>Enter first name</td><td><input type="text" name="first" /></td></tr>
<tr><td>Enter last name</td><td><input type="text" name="last" />*</td></tr>
<tr><td>Enter your age</td><td><input type="text" name="age" size="5" />*</td></tr>
<tr><td>Enter your sex</td><td><input type="text" name="sex" size="2" />*</td></tr>
<tr><td>Enter your favorite color</td><td><input type="text" name="color" /></td></tr>
<tr><td><input type="button" value="Submit" onclick="verify();" /></td></tr>
</table></form>
我正在尝试验证这些表单,但每当我单击按钮验证它们时,什么都没有发生。你能帮我解释为什么什么都没有发生吗?