RadDateTimePicker and invalid content

4 posts, 0 answers
  1. Marco
    Marco avatar
    8 posts
    Member since:
    Feb 2011

    Posted 13 Apr 2011 Link to this post

    Hi,

    When I enter some invalid data into a RadDateTimePicker, the field is marked as invalid (warning triangle and red border)- That's nice and fine.
    But when I submit the form, however, the page is considered as valid (this.IsValid returns true) and the postback is executed.

    How can I prevent the form to do a postback on invalid data?

    Thanks in advance.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Apr 2011 Link to this post

    Hello Macro,

    One suggestion to achieve this is by adding RequiredFieldValidator on the page. Using this you can show a warning message and stop the submission of the form if a required field has no value. Set the ControltoValidate property of RequiredFieldValidator to ID of RadDatePicker,.

    Please go through the following link to online demo.
    Validation

    Thanks,
    Shinu.
  3. Marco
    Marco avatar
    8 posts
    Member since:
    Feb 2011

    Posted 14 Apr 2011 Link to this post

    Hello Shinu,

    Thanks for your reply. Unfortunately, I cannot mark this field as required, because it is not a required value. Nevertheless, entering invalid data (user uses an invalid date format) has to mark the form as invalid and therefore supress the postback.

    Regards.
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Apr 2011 Link to this post

    Hello Marco,

    I would suggest you to review the following forum post in which a similar scenario is discussed and a possible approach with custom validators is provide.
    I hope this helps

    All the best,
    Maria Ilieva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top