This is a migrated thread and some comments may be shown as answers.

Validating RadDateTimePicker for valid dates?

8 Answers 336 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sasha Dossantos
Top achievements
Rank 1
Sasha Dossantos asked on 28 May 2010, 10:39 PM
I want to validate a RadDateTimePicker so a value like '4/213/2010 3:45 PM' will make the page invalid. If I manually type this value, I get a little triangle with an exclamation mark inside the textbox and the border turns red. However, when I respond to a button click in javascript and I call
            Page_ClientValidate();
            if (Page_IsValid) {
             //do stuff
           }
the Page_IsValid evaluates to true.
I see no examples in the documentation on RadDateTimePicker and how it works with the ASP .NET validators.

This is how I define my RadDateTimePicker:
                        <telerik:RadDateTimePicker ID="StartDateTextBox" runat="server" Skin="WebBlue" MaxDate=""
                            Culture="English (United States)" FocusedDate="">
                            <TimePopupButton CssClass="" ImageUrl="" HoverImageUrl=""></TimePopupButton>
                            <TimeView Skin="WebBlue" Interval="00:30:00">
                            </TimeView>
                            <DateInput InvalidStyleDuration="100" runat="server" LabelCssClass="radLabelCss_WebBlue"
                                Skin="WebBlue" >
                            </DateInput>
                            <Calendar Skin="WebBlue" ShowRowHeaders="False">
                            </Calendar>
                            <DatePopupButton CssClass="" ImageUrl="" HoverImageUrl="" />
                            <ClientEvents OnDateSelected="dateChanged" />
                        </telerik:RadDateTimePicker>

8 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 31 May 2010, 12:01 PM
Hi Sasha,

Please review the following online example which elaborates on this matter.
I hope it helps.


Regards,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sasha Dossantos
Top achievements
Rank 1
answered on 01 Jun 2010, 05:25 PM
I had looked at that link before writing the message board post. I don't see it's relevance to ensuring that the date in a raddatetimepicker is a valid date. It's comparing two times to see if one is before the other, not checking that a date such as 1/2/22010 4:15 AM cannot be submitted via a raddatetimepicker. I used the get_selectedDate method that is used in the link you provided and I get back a null when an invalid date is entered, so I guess I can create a custom validator that calls that method and sets args.IsValid to false if get_SelectedDate returns a null for a raddatetimepicker. Does that sound like a good approach?
0
Maria Ilieva
Telerik team
answered on 02 Jun 2010, 11:18 AM
Hi,

Creating Custom Validator in the described way is the best approach for your scenario. Try to implement this approach and let us know if further questions arise.


Regards,
Maria Ilieva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
pgodard
Top achievements
Rank 1
answered on 06 Dec 2010, 05:57 AM
I followed the example discussed above it works perfectly. However I have my time control on a  grid form template
    <EditFormSettings EditFormType="Template">
The update continues after the client message for custom validator is displayed. How can I cancel the update from the client side possibly inside the validate() function. Thanks.

Pierre
0
Maria Ilieva
Telerik team
answered on 08 Dec 2010, 01:11 PM
Hello Pierre,

As the provided information is not enough to correctly understand the issue you are facing and provide proper solution, could you please open a regular support ticket and send us fully runnable sample with exact steps for replicating the problem, Thus we will be able to test it locally and advise you further.


All the best,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jumpstart 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.
0
Mark Kucera
Top achievements
Rank 1
answered on 23 Mar 2012, 03:06 PM
Did you end up implementing this custom validator?  If so could you share your solution?

Thanks!

-Mark
0
Maria Ilieva
Telerik team
answered on 27 Mar 2012, 01:01 PM
Hi,

Did you review the following online example which elaborates on RadDatePicker validation and shows and option with custom validator.
If this is not what you need, please elaborate a bit more on your requirements so we could suggest proper approach for your case.

All the best,

Maria Ilieva
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.
0
Mark Kucera
Top achievements
Rank 1
answered on 27 Mar 2012, 02:52 PM
I did, thanks and I also found a separate post that had a sample file attached to it that used a  custom validator, and i was able to get that to work.
Thanks!
-Mark
Tags
Calendar
Asked by
Sasha Dossantos
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Sasha Dossantos
Top achievements
Rank 1
pgodard
Top achievements
Rank 1
Mark Kucera
Top achievements
Rank 1
Share this question
or