Required field validator not firing on date picker

10 posts, 0 answers
  1. Brendan Vogt
    Brendan Vogt avatar
    143 posts
    Member since:
    Jun 2008

    Posted 27 Aug 2008 Link to this post

    Hi,

    I have a date picker control with a required field validator control.  When the page loads the date picker's textbox is empty.  So I select a date, and then delete the date and move the focus to another control on the page, but the required field validator does not fire.  Can some one please explain why?

    Brendan
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2008 Link to this post

    Hi Brendan,

    I tried to implement the same scenario on my end and it is working as expected. Have you set the ErrorMessage property for the RequiredFieldValidator?

    Here is the aspx code I tried:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server"
          <Calendar runat="server"  Font-Size="Smaller"  ></Calendar
      </telerik:RadDatePicker> 
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter a Date" ControlToValidate="RadDatePicker1" ></asp:RequiredFieldValidator> 
           


    Regards
    Princy.
  3. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 27 Aug 2008 Link to this post

    Hello Brendan,

    I also tested the same scenario and, as Princy mentioned, it works as expected. Please set the ErrorMessage property and let us know how it goes.

    Sincerely yours,
    Maria Ilieva
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Brendan Vogt
    Brendan Vogt avatar
    143 posts
    Member since:
    Jun 2008

    Posted 27 Aug 2008 Link to this post

    Here is my code:

    <radcln:RadDatePicker
       ID="rdpExportEndDate"
       Width="120"
       runat="server">
    </radcln:RadDatePicker>
    <asp:RequiredFieldValidator
       ID="rfvExportEndDate"
       ControlToValidate="rdpExportEndDate"
       Display="Dynamic"
       ErrorMessage="Required"
       runat="server">
    </asp:RequiredFieldValidator>

    This doesn't fire at all.
  5. Brendan Vogt
    Brendan Vogt avatar
    143 posts
    Member since:
    Jun 2008

    Posted 27 Aug 2008 Link to this post

    Hi,

    I took his code, and added it to a new page, I just put it in a form tag.  That's all.  I ran the page and it does not trigger.  Is there some sort of page property that I need to set?

    Brendan
  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 27 Aug 2008 Link to this post

    Hello Brendan,

    Please find attached a sample runnable project which works as expected. Test it on your aide and let me know what the difference in your case is.

    Sincerely yours,
    Maria Ilieva
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Brendan Vogt
    Brendan Vogt avatar
    143 posts
    Member since:
    Jun 2008

    Posted 27 Aug 2008 Link to this post

    Thanks but that zipped file is too big for me to download.  Can you maybe exclude the dll files please?  I am using Q1 2007.
  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 27 Aug 2008 Link to this post

    Hi Brendan,

    Please find the attached project. Add the needed dll's and let us know how it goes.

    Greetings,
    Maria Ilieva
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Brendan Vogt
    Brendan Vogt avatar
    143 posts
    Member since:
    Jun 2008

    Posted 28 Aug 2008 Link to this post

    Hi,

    I had a look at the code.  The required field validator only fires when the button is clicked and there is no date.  My scenario is different.  When there is a date and the user clears the date and goes to another control, then it should fire, not only when the button is clicked.

    Brendan
  10. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 28 Aug 2008 Link to this post

    Hello Brendan,

    The default behaviour of the Validator control is to to fire validation on postback. I you add regular asp control instead of RadDatePicker the application will behaves in the same way. Please review the following topic which elaborates on Validating control on lost focus event

    Kind regards,
    Maria Ilieva
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top