I have created customized content model where 2 date control are there.
Now I want populate ToDate whenever FromDate change(base on some logic) and another is validation where ToDate should not be greater than FromDate(I have achieved this thing using validation-handler but the problem is it calling on every field of that form on keyup event).
Have any one implemented this type of thing?
<field id="mbs:dosRangeTo" set="chargeBatchDocument" mandatory="true"> <control template="/org/alfresco/components/form/controls/dos_to_date.ftl"/> <constraint-handlers> <constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.validateMyDate" event="keyup" message="From Date Should not be greater than To Date"/> </constraint-handlers> </field>
Alfresco.forms.validation.validateMyDate = function validateMyDate(field, args,event, form, silent, message)
As dos_to_date.ftl component is not oob alfresco component, so you need to add content of it.
You can use daterange control of alfresco.If required you can customize it as well.It is saving from date and to date separated by pipe("|"), so you will be able to validate it inside the, validation handler.
Validation handler is component of form and not the component of any particular field.So whenever any field will gget changed it will try to validate all fields(by calling all validation handler).Validation handler will get called at the time of form submission as well.
If you would like to do something apart from validation you can do it inside, date-range.js file.Use Extension mechanism for extending it.
I'm trying to do the pretty much the same thing as Sanjay, input Start date and End date and validate the end date is greater than start date. I'm trying to use the daterange.ftl control, it shows normally in my form however the icon form datepicker is kind of disabled, it doesn't open the datepicker to select a date and therefore it's impossible to fill in the date. For some reason, whenever i put the daterange.ftl,all datepickers would stop working within the form.