Page 1 of 1

Datetime validation

Posted: Fri May 03, 2019 2:07 am
by HeshanKaru1994
I would like to validate datetime control. Initially the current month should be used to this process.

If the current month between Jan-June then July to Dec should be disabled.
If the current month between July-Dec then Jan to June should be disabled.

Can I know whether this is possible

Thank you

Re: Datetime validation

Posted: Fri May 03, 2019 10:14 pm
by amosbatto
Are you limiting the date to the current year?

Create the following trigger:
Code: Select all
$nMonth = (int) date("m");
if (nMonth < 7) {
    @@minDate = date("Y-01-01"); //Y will be replaced with the current year
    @@maxDate = date("Y-06-30"); 
}
else {
    @@minDate = date("Y-07-01"); 
    @@maxDate = date("Y-12-31");
} 
Set this trigger to fire before the Dynaform containing the datatime field.

Then, in the properties of your datetime field, set the min date property to: @@minDate
and set the max date property to: @@maxDate

This example will help you: https://wiki.processmaker.com/3.2/Datet ... _variables

Re: Datetime validation

Posted: Fri May 03, 2019 10:26 pm
by HeshanKaru1994
Thank you works well

Re: Datetime validation

Posted: Fri May 03, 2019 10:45 pm
by HeshanKaru1994
But the datetime field does not vaidate minDate and maxDate

Re: Datetime validation

Posted: Mon May 06, 2019 9:04 pm
by amosbatto
The min date and max date properties limit the dates that can be selected with the date picker and datetime fields won't let you manually enter a date outside the bound.

If you don't see that, you probably didn't set something correctly. Here is a sample process to demonstrate it:
(24.48 KiB) Downloaded 555 times