This is a migrated thread and some comments may be shown as answers.

[Solved] How to swith IsRequired off ?

1 Answer 120 Views
Input
This is a migrated thread and some comments may be shown as answers.
juststarting
Top achievements
Rank 2
juststarting asked on 20 Nov 2009, 08:13 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 20 Nov 2009, 10:52 AM
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.
Tags
Input
Asked by
juststarting
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or