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

RadCombo box and required field validator - why check input text and not value?

2 Answers 110 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 21 Jun 2013, 08:49 AM
The required field validator for radcombobox seems to activate only when the selected item has no text. Shouldn't it be activating when the selected item has no value instead? If I want to set some default text in the combo box, such as "Please choose a value", like the example below, what do I have to do to to make the required field validator activate when the first item is chosen? (Value = "" Text ="Please choose a value"

<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
 SkinID="DropDownList" TabIndex="17" Width="240px">
    <Items>
        <telerik:RadComboBoxItem Value="" Text="Please choose a value" />
        <telerik:RadComboBoxItem Value="value2" Text="item2" />
        <telerik:RadComboBoxItem Value="value3" Text="item3" />
        <telerik:RadComboBoxItem Value="value3" Text="item3" />
    </Items>
</telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rfvCountry" runat="server" ControlToValidate="RadComboBox1"
    ErrorMessage="Country is required" SkinID="RequiredFieldValidator">
</asp:RequiredFieldValidator>
"Please choose a value"

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Jun 2013, 10:27 AM
Hi,

Try setting 'InitialValue' property of RequiredFieldValidator as shown below.

<asp:RequiredFieldValidator ID="ReqValTest" runat="server" ControlToValidate="rcmbTest"  InitialValue="Please choose a value" ErrorMessage="Error" Display="Static"></asp:RequiredFieldValidator>

Thanks,
Shinu.
0
Joey
Top achievements
Rank 1
answered on 22 Jun 2013, 04:38 AM
Thanks Shinu, works perfectly
Tags
ComboBox
Asked by
Joey
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Joey
Top achievements
Rank 1
Share this question
or