How to swith IsRequired off ?

2 posts, 1 answers
  1. juststarting
    juststarting avatar
    18 posts
    Member since:
    Jul 2012

    Posted 20 Nov 2009 Link to this post

    Hi,

    I have 3 fields on a webpage. I need to make sure that at least 2 of the 3 being completed (any combination). So I added a RadInputManager and added the TargetInput Controls for all 3. This require the client to complete all 3. Is there a way to do this that only 2 of the 3 needs to be completed?

    Thanx in advance for all help.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2009 Link to this post

    Hello,

    Try the followong approach by using CustomValidator control in order to validate the textboxes.

    ASPX:
     
        <telerik:RadTextBox ID="RadTextBox1" runat="server"
        </telerik:RadTextBox><br /> 
        <telerik:RadTextBox ID="RadTextBox2" runat="server"
        </telerik:RadTextBox><br /> 
        <telerik:RadTextBox ID="RadTextBox3" runat="server"
        </telerik:RadTextBox><br /> 
        <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="validate" 
            ErrorMessage="CustomValidator"></asp:CustomValidator> 
        <asp:Button ID="Button1" runat="server" Text="Button" /> 

    JavaScript:
     
    <script type="text/javascript"
    function validate(sender, arg) 
        var textbox1 = $find("<%= RadTextBox1.ClientID %>"); 
        var textbox2 = $find("<%= RadTextBox2.ClientID %>"); 
        var textbox3 = $find("<%= RadTextBox3.ClientID %>"); 
        var value1 = textbox1.get_value(); 
        var value2 = textbox2.get_value(); 
        var value3 = textbox3.get_value();     
        if((value1=="" && value2=="")||(value1=="" && value3=="")||(value2=="" && value3=="")) 
        {     
            arg.IsValid = false
        } 
    </script> 

    Regards,
    Shinu.
Back to Top