我要实现的功能是:如果CHECKBOX1选中了,那么INPERTBOX这个文本框用户可以不输入,如果没选中,必须输入?怎么做?我现在在调试的第一步,用自定义控件,都没有成功。哭了,救救我<asp:CustomValidator id="CustomValidator1" runat="server" ClientValidationFunction="validate" ControlToValidate="inputperson"
ErrorMessage="如果不选择匿名发表,请输入您的昵称" Display="None"></asp:CustomValidator>
<script language="javascript">
<!--
function validate(source,arguments)
{
if (arguments.Value.length == 0)
{
arguments.IsValid=false;
}
else
{
arguments.IsValid=true;
}
}
// -->
</script>
ErrorMessage="如果不选择匿名发表,请输入您的昵称" Display="None"></asp:CustomValidator>
<script language="javascript">
<!--
function validate(source,arguments)
{
if (arguments.Value.length == 0)
{
arguments.IsValid=false;
}
else
{
arguments.IsValid=true;
}
}
// -->
</script>
高级选项中慢慢找.
有其他方法吗?
{
alert("如果不选择匿名发表,请输入您的昵称"");
document.form.inpentbox.focus();
return false;
}
if(!document.form.checkbox1.checked && document.form.inpentbox.text == "")
{
alert("如果不选择匿名发表,请输入您的昵称"");
document.form.inpentbox.focus();
return false;
}
稍微改一下