我要实现的功能是:如果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>

解决方案 »

  1.   

    在IE中打开javascript的调试就可以知道为什么了.
    高级选项中慢慢找.
      

  2.   

    CustomValidator 只有在提交时才会验证
      

  3.   

    我要实现的功能是:如果CHECKBOX1选中了,那么INPERTBOX这个文本框用户可以不输入,如果没选中,必须输入?怎么做?
    有其他方法吗?
      

  4.   

    if(document.form.checkbox1.checked==false&document.form.inpentbox.text=="")
    {
     alert("如果不选择匿名发表,请输入您的昵称"");
     document.form.inpentbox.focus();
     return false;
    }
      

  5.   

    wangjanson99(人在天涯) ( ) 信誉:100  2006-03-09 16:26:00  得分: 0  
    if(!document.form.checkbox1.checked && document.form.inpentbox.text == "")
    {
     alert("如果不选择匿名发表,请输入您的昵称"");
     document.form.inpentbox.focus();
     return false;
    }
    稍微改一下