jascript中radio及checkbox应用

document.form.radio1.checked

document.form.radio1.value

 

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>当前位置</title>
</head>

<body>
<script language="javascript">
function CheckLogin() {
var t=document.Login.Type
var TF=false;
for (i=0 ; i<t.length;i++)

if (t[i].checked)
{   
TF=true; break; 
}
}

if (TF==false) 
{   
alert("请选择用户类型!"); 
return false; 
}

if (document.Login.UserName.value=="") 
{   
alert("请输入用户名!"); 
document.Login.UserName.focus(); 
return false; 
}

if (document.Login.PassWord.value=="") 
{   
alert("请输入密码!"); 
document.Login.PassWord.focus(); 
return false; 

}
</script> 
<table width="980" align="center"  border="0" cellspacing="0" cellpadding="0" class="m_bg_t">
<form name="Login" action="ChkLogin.asp" onSubmit="return CheckLogin()"> 
<tr>   
<td width="20%">&nbsp; &nbsp;当前位置:<a href='../'>首页</a> -->> <a href='../PersonInfor/'>个人服务</a> </td>   
<td width="6%"class="td_pb5"><input type="radio" name="Type" value="1" />    个人</td>   

<td width="2%"><img src="../images/geren_icon.gif" width="10" height="16" /></td>   
<td width="6%" class="td_pb5"><input type="radio" name="Type" value="2" />    企业</td>

<td width="2%"><img src="../images/qiye_icon.gif" width="10" height="16" /></td>   

<td width="6%">用户名:</td>   
<td width="14%"><input name="UserName" type="text"class="input_zc" id="UserName" size="20" maxlength="20" /></td>   
<td width="5%"><div align="center">密 码:</div></td>   
<td width="15%"><input name="PassWord" type="password"class="input_zc" id="PassWord" size="20" maxlength="20" /></td>   
<td width="9%"><input type="image" src="../images/login.gif" width="77" height="21" /></td>   
<td width="15%"><a href="../PersonInfor/PersonReg.html">个人注册</a>  <a href="../CompanyInfor/CompanyReg.html">企业注册</a></td> 
</tr> 
</form>
</table>
</body>

</html>

你可能感兴趣的:(checkbox)