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

3 posts, 0 answers
  1. Joey
    Joey avatar
    27 posts
    Member since:
    Jun 2013

    Posted 21 Jun 2013 Link to this post

    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. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Jun 2013 Link to this post

    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.
  3. Joey
    Joey avatar
    27 posts
    Member since:
    Jun 2013

    Posted 21 Jun 2013 Link to this post

    Thanks Shinu, works perfectly
Back to Top