2011-11-07 62 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.

相關問題