客户端表单验证 单选按钮是否被选中 5
scriptlanguage="javascript"><!--functiontest(form){if(form.options.value=="new"&&Form...
script language="javascript">
<!--
function test(form)
{
if (form.options.value == "new" && Form.flag.checked == false)
{ alert('用户类型不能为空!');return false;}
}
function test(form) {
if ((form.options.value == "rename" && form.reTitle.value == "") || (form.options.value == "new" && form.newTitle.value == "") || (form.options.value == "new" && form.flag.checked == false))
{alert("您没有填写专题名称或类别,请填写");return false;}
if (form.options.value == "del")
{return confirm("将同时删除该专题中的所有内容!是否继续?");}
return true;
}
//-->
</script>
<body bgcolor="#FFFFFF">
<br>
<form name="form" id="form" method="POST" action="typefrom.asp" align="center" language="javascript" onSubmit="return test(this);">
<input type="hidden" name="options" value>
<table border="0" cellpadding="0" cellspacing="1" width="95%" align="center">
<tr>
<td align="center" bgcolor="#CCCCCC">
<p>类别:
<select name="subject" size="1"
style="font-size: 9pt">
<%
Do while not rs.eof
response.write "<option value='" + Cstr(rs("cpfl_id")) + "'>" + rs("cpfl_name") + "</option>"
rs.MoveNext
Loop
%>
</select>
<input type="submit" value="删除" name="B2" class=buttonface onClick="form.options.value='del'" >
</td>
</tr>
<tr align="center">
<td bgcolor="#F6F6F6"> </td>
</tr>
<tr align="center">
<td bgcolor="#CCCCCC">
<p>新名字:
<input type="text" name="reTitle" size="20" class=smallinput>
<input type="submit" value="改名" name="B1" class=buttonface onClick="form.options.value='rename'">
</td>
</tr>
<tr align="center">
<td bgcolor="#F6F6F6"> </td>
</tr>
<tr align="center">
<td bgcolor="#CCCCCC">
<p>新类别:
<input type="text" name="newTitle" size="20" class=smallinput>
中文类别:
<input name="flag" type="radio" value="1">
英文类别:
<input name="flag" type="radio" value="0">
<input type="submit" value="新增" name="B3" class=buttonface onClick="form.options.value='new'"></td>
</tr>
</table>
</form>
这个程序怎样验证单选按钮为为空时进行验证 ,现在不好用??????
根据我的程序 给我改了能用了行!在客户端验证!?????????????????????????????????????????????????? 展开
<!--
function test(form)
{
if (form.options.value == "new" && Form.flag.checked == false)
{ alert('用户类型不能为空!');return false;}
}
function test(form) {
if ((form.options.value == "rename" && form.reTitle.value == "") || (form.options.value == "new" && form.newTitle.value == "") || (form.options.value == "new" && form.flag.checked == false))
{alert("您没有填写专题名称或类别,请填写");return false;}
if (form.options.value == "del")
{return confirm("将同时删除该专题中的所有内容!是否继续?");}
return true;
}
//-->
</script>
<body bgcolor="#FFFFFF">
<br>
<form name="form" id="form" method="POST" action="typefrom.asp" align="center" language="javascript" onSubmit="return test(this);">
<input type="hidden" name="options" value>
<table border="0" cellpadding="0" cellspacing="1" width="95%" align="center">
<tr>
<td align="center" bgcolor="#CCCCCC">
<p>类别:
<select name="subject" size="1"
style="font-size: 9pt">
<%
Do while not rs.eof
response.write "<option value='" + Cstr(rs("cpfl_id")) + "'>" + rs("cpfl_name") + "</option>"
rs.MoveNext
Loop
%>
</select>
<input type="submit" value="删除" name="B2" class=buttonface onClick="form.options.value='del'" >
</td>
</tr>
<tr align="center">
<td bgcolor="#F6F6F6"> </td>
</tr>
<tr align="center">
<td bgcolor="#CCCCCC">
<p>新名字:
<input type="text" name="reTitle" size="20" class=smallinput>
<input type="submit" value="改名" name="B1" class=buttonface onClick="form.options.value='rename'">
</td>
</tr>
<tr align="center">
<td bgcolor="#F6F6F6"> </td>
</tr>
<tr align="center">
<td bgcolor="#CCCCCC">
<p>新类别:
<input type="text" name="newTitle" size="20" class=smallinput>
中文类别:
<input name="flag" type="radio" value="1">
英文类别:
<input name="flag" type="radio" value="0">
<input type="submit" value="新增" name="B3" class=buttonface onClick="form.options.value='new'"></td>
</tr>
</table>
</form>
这个程序怎样验证单选按钮为为空时进行验证 ,现在不好用??????
根据我的程序 给我改了能用了行!在客户端验证!?????????????????????????????????????????????????? 展开
2个回答
展开全部
那你在做这个单选按钮时,把它的那个Value设为一个数0或是1,之类的, 到时用的时候,if request.from("那个单选按钮的名")=Value(所写的那个值),这样就可以 了吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询