datetime validation of two datetime components

Avatar

Avatar

beginner_398712

Avatar

beginner_398712

beginner_398712

15-10-2015

Hello

I have a in a dialog two datetime fields, start and end datetime.
I want to validate that the startdate < enddate, but I couldn't find anyway to do this with the api.
I tried to use the change event but it is only fired when the dialog is coming up and when you press ok, not when you actually change a value on the field. I also tried some of the other events but none of them is fired when you actually change a data or a time.
I also tried to replace this component with two component a datefield and a timefield because they provide the possibility to define a validator but you only get the value and not you do not get access to the component that fired the event so I cannot get access to the second component to compare the two fields.
I found another solution on the web about using the beforerender event to setup the min max values but again this event is only fired once at the begining
this is how the relevant part of the dialog looks like

<date                         jcr:primaryType="cq:Widget"                         collapsed="{Boolean}false"                         collapsible="{Boolean}false"                         itemId="date"                         title="Date"                         xtype="dialogfieldset">                         <items jcr:primaryType="cq:WidgetCollection">                             <eventScheduledStartDate                                 jcr:primaryType="cq:Widget"                                 allowBlank="{Boolean}false"                                 fieldLabel="Scheduled start for"                                 ignoreData="false"                                 itemId="eventScheduledStartDate"                                 name="./cs_17585:eventScheduledStartDate"                                 tooltip="Define the scheduled start date and time for the event"                                 xtype="datetime"/>                             <eventScheduledEndDate                                 jcr:primaryType="cq:Widget"                                 fieldLabel="Scheduled end for"                                 ignoreData="false"                                 itemId="eventScheduledEndDate"                                 name="./cs_17585:eventScheduledEndDate"                                 tooltip="Define the scheduled end date and time for the event"                                 xtype="datetime"/>                                                            </eventScheduledEndDate>                         </items>                     </date>  
View Entire Topic

Avatar

Avatar

beginner_398712

Avatar

beginner_398712

beginner_398712

15-10-2015

This is about validating a single datetime component and they recommend the use of the min max values together with the beforerender event which I already tried and it does not work as this is fired only once when the dialog is shown.

Any other ideas on how to validate two datetime fields that startDatetime < endDatetime