<script type="text/javascript">
function mycheck(){
if(myform.user.value==""){
alert("username can't be empty!");
myform.user.focus();
return false;
}
if(myform.psw.value==""){
alert("password can't be empty!");
myform.psw.focus();
return false;
}
return isRadioCheck();
return isCheckBoxCheck();//这儿没起作用
}
function isRadioCheck(){
var i;
for(i=0;i<myform.coname.length;i++){
if(myform.coname[i].checked){
return true;
}
}
alert("You must choose a company!");
return false;
}
function isCheckBoxCheck(){
var i;
var checkName = document.myform.getElementsByName ("page[]");
for(i=0;i<checkName.length;i++){
if(checkName[i].checked){
return true;
}
}
alert("You must choose a page!");
return false;
}</script>HTML表单<form action="?pg=estate&ac=insertuser" method="post" name="myform">
<table width=800 border=1>
<th height=40 colspan=2 bgcolor=lavender>Create User Access To Estate</th>
<tr>
<tr>
<td height=30 colspan=2 align=center><a href="?pg=map" target="_blank">Go To Google Maps</a> |<a href="?pg=estate&ac=listuser">List Current Users</a> | <a href="?pg=estate&ac=adduser">Add New User</a> | <a href="?pg=estate&ac=listestate">List Estate</a> | <a href="logout.php">Logout</a></td>
</tr>
<tr>
<td colspan=2 align=center><p class="cbh_tdc">Please Enter A User name and Password For This Contact</p></td>
</tr>
<tr>
<td bgcolor=lavender> Name:
<input type="text" name="user"></td>
<td bgcolor=lavender>Password:
<input type="text" name="psw"></td>
</tr>
<tr>
<td colspan=2 align=center><p class=cbh_tdc>Please Select The Business or Businesses associated with this contact:</p></td>
</tr>
<tr>
<td height=100 colspan=2 bgcolor=lavender><table width=100%>
<tr> %%HTML%% </tr>
</table></td>
</tr>
<tr>
<td colspan=2 align=center><p class=cbh_tdc>Please Select The Real Estate Pages This Contact Can Update</p></td>
</tr>
<tr>
<td bgcolor=lavender><input type="checkbox" name="page[]" value="agent" />
Agent
<input type="checkbox" name="page[]" value="rec" />
Real Estate Company </td>
<td><input type=submit value=Submit onclick="return mycheck();" /></td>
</tr>
</tr>
</table>
</form>
就是复选框不能验证
return isRadioCheck(); //<== 你在这里就返回了,下面一句如何执行?
return isCheckBoxCheck();//这儿没起作用
}
return isRadioCheck(); //这儿的return 去掉
return isCheckBoxCheck();//这儿没起作用
}