Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in ASP.NET MVC > RadDatePicker validation

Not answered RadDatePicker validation

Feed from this thread
  • Ratna Koneru avatar

    Posted on Sep 21, 2009 (permalink)

    Is there a way to suppress the validation fired by RadDatePicker when an invalid date(13/13/2001) is entered and display the error message from a custom validator? Basically, I just want to show the error message from custom validator and don't want to show the information icon that RadDatePicker usually shows when an invalid date is entered.

    Reply

  • Mira Mira admin's avatar

    Posted on Sep 24, 2009 (permalink)

    Hi Ratna,

    I am attaching a sample project I made for you in which OnValueChanging client event of the DateInput of the RadDatePicker is handled. On invalid user input custom message is displayed and the event is canceled.

    Please take a look at it and tell me whether you find it useful.


    Regards,
    Mira
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Ratna Koneru avatar

    Posted on Sep 24, 2009 (permalink)

    Hi Mira,
           Thanks for the sample. I tried the code you sent. It still behaves the same way when an invalid date (13/13/2001) is keyed. The other difference I saw is if you key in a date (010101 or 01012001 for 01/01/2001) it shows it as invalid because of parsing. The date is supposed to be Valid. Also, at this point the validation of the datepicker doesn't fire and only the error message shows up, which is what I was looking for even in case we enter 13/13/2001.

    Thanks,
    Sunil Koneru

    Reply

  • Mira Mira admin's avatar

    Posted on Sep 25, 2009 (permalink)

    Hi Ratna,

    Thank you for the further clarifications.

    To achieve the desired by you functionality I recommend that you use the build-in validation of the RadDatePicker and handle the OnError client event. In its event handler you can display the custom error message and cancel the event.

    I am also attaching a sample project showing how this works. I hope you will find it useful.

    Best wishes,
    Mira
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • Ratna Koneru avatar

    Posted on Sep 28, 2009 (permalink)

    The solution worked. Thanks.

    Reply

  • Ratna Koneru avatar

    Posted on Sep 29, 2009 (permalink)

    One more question related to DatePicker validation, Is there a way we can retain the value entered without using javascript? Is there a property like RetainValue (or something like that) which will retain the invalid value entered, when 'OnError' event triggers, with the same behaviour as mentioned before?

    Thanks,
    Sunil

    Reply

  • Mira Mira admin's avatar

    Posted on Oct 1, 2009 (permalink)

    Hi Ratna,

    Note the DateInput value is set only in case of valid input. In case of invalid input the OnError client-side event is fired and the DateInput/DatePicker value is left unchanged. Therefore you can get the invalid input in the OnError client-side event handler only and use it as per your requirements further.

    Best wishes,
    Mira
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

    Reply

  • M Givi avatar

    Posted on Oct 15, 2009 (permalink)

    thanks. It worked for me.

    Reply

  • Peter Livsey avatar

    Posted on Oct 10, 2011 (permalink)

    Is there a property that can be set on the RadDatePicker to stop the validation event firing? If possible I'd rather not rely on using Javascript in the ClientEvents to stop the override the default validation by doing 'eventArgs.set_cancel(true);'

    Peter

    Reply

  • Mira Mira admin's avatar

    Posted on Oct 12, 2011 (permalink)

    Hello Peter,

    You can use the following code in order to cancel the OnError event and make the picker keep the old date (the last one valid):
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <DateInput ClientEvents-OnError="HandleError">
        </DateInput>
    </telerik:RadDatePicker>
    <script type="text/javascript">
        function HandleError(sender, eventArgs) {
            eventArgs.set_cancel(true);
        }
    </script>

    I hope this helps.

    Best wishes,
    Mira
    the Telerik team
    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 their blog feed now

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in ASP.NET MVC > RadDatePicker validation