RequiredFieldValidator not working

8 posts, 0 answers
  1. Joe
    Joe avatar
    57 posts
    Member since:
    Mar 2013

    Posted 29 Jul 2013 Link to this post

    I had added a RequiredFieldValidator to dropdownlist that make sure user had selected value before insert to db. but the checking is not working that will not prompt error message.

    <telerik:RadDropDownList ID="rdl_bu" runat="server" DataSourceID="LDS_BU" DefaultMessage="Please select..."
     DataValueField="BU_ID" DataTextField="BU_name" AutoPostBack="true" >
    </telerik:RadDropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="rdl_bu"
             InitialValue="Please Select..." ErrorMessage="Please select a Business Unit."></asp:RequiredFieldValidator>
  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 29 Jul 2013 Link to this post

    Hello,

    Please remove the 
    InitialValue="Please Select..."

    property from your Requiredfieldvalidator.

    Thanks,
    A2H
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Edim
    Edim avatar
    1 posts
    Member since:
    Sep 2012

    Posted 13 Aug 2013 Link to this post

    Thanks for your answer. i solved the validation problem. when delete the initial value="" property from requiredfield validator
  5. Parul
    Parul avatar
    2 posts
    Member since:
    Jan 2013

    Posted 21 Nov 2013 Link to this post

    I have the following code for my RadDropDownList ; The Required Field Validator is not being fired. I removed the Initial Value ="0" also. It works fine when I use asp:dropdownlist. Any help will be appreciated.


    <telerik:RadDropDownList runat="server" ID="ddlPatients" Width="358px">
                </telerik:RadDropDownList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ErrorMessage="Patient ID is Required"
                  ControlToValidate="ddlPatients" runat="server" Text="<img src='../App_Themes/Images/exclamation.png' />"
                  SetFocusOnError="True" />
  6. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 26 Nov 2013 Link to this post

    Hello Parul,

    If this is the very same implementation that you are using at your end, the RadDropDownList would be populated, with setting its first item as selected. In this case the validation would pass, because a PatientID is actually selected. If you want to push the user to select an item different from the first one, you could set the InitialValue property of the Required Field Validator and set first item's Text to the InitialValue property, like demonstrated in this video. Other possible implementation would be to set the DefaultMessage property of the RadDropDownList. Thus you would avoid preselecting the first item of the DropDownListItemsCollection, like demonstrated in this video.


    Regards,
    Nencho
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  7. Parul
    Parul avatar
    2 posts
    Member since:
    Jan 2013

    Posted 26 Nov 2013 Link to this post

    I used the property set DefaultMassage and works for me.

    Thanks
  8. Oscar
    Oscar avatar
    16 posts
    Member since:
    Sep 2013

    Posted 04 Jun 2014 in reply to Nencho Link to this post

    Hi Nencho, 

    I know this post have some time already. I was having the same issue with rad ddl and required field validators and your video help me out. But, what I realized is that there is something odd about required field validator, because, why is it called "InitialValue" if it is considering the Text of the dropdownlist item?

    I was always using on my asp.net dropdownlists the Text="- Select -" and the Value="", so my first guess to solve my issue was to put InitialValue="" but it was not working. By checking your video l saw that it was expecting the Text "- Select -" to work properly.

    Maybe the property should be called "InitialText" and not "InitialValue" what do you think?, or better: it should be checking the value property from dropdownlist and not the selected text.

    Regards



  9. Nencho
    Admin
    Nencho avatar
    1457 posts

    Posted 09 Jun 2014 Link to this post

    Hello Oscar,

    Indeed, the naming convention could be differently interpreted and sometimes it could cause such misunderstanding. However, I am afraid that the asp:RequiredFieldValidator is not under our jurisdiction and we would have to accept it as it is.

    Regards,
    Nencho
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017