ASP.NET: Custom client-side validator for “one of two fields must be filled”?

Can you tell me if there anybody has implemented a custom validator for checking that one of two (or N) input fields are filled?

   "Insert phone number or email address"

I'm using ASP.NET (Ajax) 3.5, the ajaxToolkit:ValidatorCalloutExtender (and jQuery if it's necessary).


I just did this (requires jQuery):


function validatePhoneOrEmail(source, args) {
    if ($("[id$='txtEmail']").val() == "" && $("[id$='txtTel']").val() == "") 
        args.IsValid = false;
        args.IsValid = true;


<asp:CustomValidator runat="server" 
    ErrorMessage="Please enter a telephone number or email address">

I don't have any server-side validation for this, but I'm assuming a similar function in the server would be pretty easy to create.

Need Your Help

How do I graph simple X-Y data in Teechart?

delphi teechart fastreport

I'm using Delphi and Fast reports, specifically the TeeChart object inside Fast Reports.

Mapping a function over a multidimensional array in scala

arrays scala map multidimensional-array

I know there is a clean way to map a function f:A =&gt; B over an array, foo of type Array[A] to get an Array[B] via{f}.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.