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

RadDateTimePicker demo

6 Answers 37 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
miksh
Top achievements
Rank 1
Iron
miksh asked on 24 Apr 2014, 04:21 PM
I suggest you to review your online demo in "Time picker/DateTime picker" section and add more demo/info re. RadDateTimePicker. Specifically, I would suggest:
  • Add "DateTimePicker - First Look"
  • MOST IMPORTANT: Add DateTimePicker range validation as it's different from TimePicker!            

6 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Apr 2014, 07:51 AM
Hello Michael,

Thank you for your feedback and for your suggestions.

I will forward your suggestion for online demos regarding the RadDateTimePicker control, but in general, the control is combination between RadDatePicker and RadTimePicker, and detailed information for both controls is available at out online demos and help articles.

Furthermore, the same demo for RadTimePicker validation could be used with RadDateTimePicker control by just changing the control:
<telerik:RadScriptBlock runat="server" ID="RadCodeBlock1">
    <script type="text/javascript">
        //<![CDATA[
        var RadTimePicker1;
        var RadTimePicker2;
 
        function validate(sender, args) {
            var Date1 = new Date(RadTimePicker1.get_selectedDate());
            var Date2 = new Date(RadTimePicker2.get_selectedDate());
            args.IsValid = true;
            if ((Date2 - Date1) < 0) {
                alert("The second time value should be greater than the first!");
                args.IsValid = false;
            }
        }
 
        function onLoadRadTimePicker1(sender, args) {
            RadTimePicker1 = sender;
        }
 
        function onLoadRadTimePicker2(sender, args) {
            RadTimePicker2 = sender;
        }
        //]]>
    </script>
</telerik:RadScriptBlock>
 
<telerik:RadDateTimePicker ID="RadTimePicker1" runat="server">
    <DateInput ID="DateInput1" runat="server">
        <ClientEvents OnLoad="onLoadRadTimePicker1"></ClientEvents>
    </DateInput>
</telerik:RadDateTimePicker>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadTimePicker1"
    ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
 
<telerik:RadDateTimePicker ID="RadTimePicker2" runat="server">
    <DateInput ID="DateInput2" runat="server">
        <ClientEvents OnLoad="onLoadRadTimePicker2"></ClientEvents>
    </DateInput>
</telerik:RadDateTimePicker>
<asp:RequiredFieldValidator runat="server" ID="Requiredfieldvalidator2" ControlToValidate="RadTimePicker2"
    ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
 
<asp:CustomValidator ID="CustomValidator1" EnableClientScript="true" runat="server"
    ControlToValidate="RadTimePicker2" ClientValidationFunction="validate">
</asp:CustomValidator>
<asp:Button runat="server" Text="Save" ID="Button1"></asp:Button>

Please feel free to get back to us If you need any further assistance with the validation.


Regards,
Konstantin Dikov
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.

 
0
miksh
Top achievements
Rank 1
Iron
answered on 29 Apr 2014, 12:04 PM
Thanks Konstantin, I'll try this approach - I believe it would work.

Could you comment the note made in http://www.telerik.com/help/aspnet-ajax/calendar-validation.html

You need to set the Type property of the CompareValidator to "Date" in order to work with a RadDatePicker. When working with RadTimePicker, or RadDateTimePicker control, the property must be set to "String".

Would it be simpler solution or your documentation is incorrect?
0
Konstantin Dikov
Telerik team
answered on 02 May 2014, 08:31 AM
Hello Miksh,

The help article that you are referring to demonstrates how to use CompareValidator for comparing two dates. On the other hand, the online demo is using CustomValidator, and since the validation is handled manually, the same approach could be used with both - RadDatePicker and RadDateTimePicker.

As for which approach should be demonstrated in the help article, since comparing values from pickers with CompareValidator has its specifics and the CustomValidator could implement any custom logic, in my opinion the CompareValidator approach is more suitable for help article.


Best Regards,
Konstantin Dikov
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.

 
0
miksh
Top achievements
Rank 1
Iron
answered on 02 May 2014, 12:31 PM
Ok thank you. So in general case I would prefer to use CompareValidator as the simplest solution. 
The only concern, since it uses a string value to compare would it work for any culture?
0
Princy
Top achievements
Rank 1
answered on 05 May 2014, 05:11 AM
Hi miksh,

The CompareValidator will work with Culture property of RadDatePicker. Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadDatePicker ID="StartDate" MinDate="2008/1/1" runat="server" Culture="fr-FR">
</telerik:RadDatePicker>
<telerik:RadDatePicker ID="EndDate" MinDate="2008/1/1" runat="server" Culture="en-US">
</telerik:RadDatePicker>
<asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="EndDate"
    ControlToCompare="StartDate" Operator="GreaterThan" Type="Date" ErrorMessage="The end date must be after the start one.">
</asp:CompareValidator>
<asp:Button runat="server" Text="Submit" ID="Button1" />

Thanks,
Princy.
0
Accepted
Konstantin Dikov
Telerik team
answered on 07 May 2014, 06:32 AM
Hello Miksh,

As Princy pointed out (and as documented in our help article RadCalendar - Web Pages Validation), when you use RadDatePicker you could use the CompareValidator by setting the Type to "Date", and when RadDateTimePicker is used, the Type should be set to "String".

In general, the validation for RadDateTimePicker should work correctly, regardless the used culture.


Best Regards,
Konstantin Dikov
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.

 
Tags
Calendar
Asked by
miksh
Top achievements
Rank 1
Iron
Answers by
Konstantin Dikov
Telerik team
miksh
Top achievements
Rank 1
Iron
Princy
Top achievements
Rank 1
Share this question
or