2011-11-07 37 views

回答

1

属性“ControlToValidate”不允许您设置一些控件。你应该编写你自己的验证器,例如使用JS。

0

尝试没有给予任何控制器ControlToValidate,给自己ClientValidationFunction

<asp:CustomValidator id="AtLeastOneContact" runat="server" 
    ErrorMessage="Phone or Email Required" 
    Display="Dynamic" 
    OnServerValidate="AtLeastOneContact_ServerValidate" 
    ClientValidationFunction="AtLeastOneContact_ClientValidate" /> 

客户端验证

<script type="text/vbscript" language="vbscript"> 
<!-- 
    Sub AtLeastOneContact_ClientValidate(source, args) 
     'Requires that either Phone or Email is not empty 

     If document.getElementById("<%= Phone.ClientID %>").value & _ 
      document.getElementById("<%= Email.ClientID %>").value <> "" Then 
      args.IsValid = true 
     Else 
      args.IsValid = false 
     End If 
    End Sub 
'--> 
</script> 

check this for more information.

相关问题