Buy Now
Sign in

Calculate End date starting from a condition expressed in months

CarmeloDev91 , January 31 2020, 15:08
CarmeloDev91 2
January 31 2020, 15:08 #390979
Hi guys! I need advice on the creation of a form that allows me to calculate dates with a condition ...
Users enter the date in the form in the MM / YYYY format and in another of the multiples of 12 (from 12 to 120 months) which would be the months in which they made a loan ...
Now from these 2 forms I have to give a condition to process the result:
If they select from 12 to 60 months on the inserted date, they must give the MM / YYYY + one year result

EXAMPLE: if they enter 08/2019 and 48 months it should result in the date 08/2019 + one year i.e. 08/2020 with a popup warning that it is tied to a 120 month loan

If they select from 72 to 120 months, 40% of the multiples from 72 to 120 must be calculated and added to the date in MM / YYYY format
EXAMPLE: if they enter 08/2019 and 120 months it should result in the date 08/2019 + 40% of 120 or 48 months (4 years) ie 08/2023 so it should appear once clicked on calculate: "You can renew the loan from 08/2023 "

Is it possible to do this with Chronoform form builders?
If yes, how should I do it?
What formulas should I set?

Thanks to those who will be able to help!
healyhatman 9
February 01 2020, 00:37 #390992
On the front end you'd have to use the moment.js library (included). In the FAQs there's a post on creating a custom validation, just need to add the moments code to it. Something like moment(jQuery('#field_id').val()).isAfter(moment(jQuery('#field_id').val()) + ' + 1 year') or something along those lines.
In the backend you'd want to use PHP and datetime.
Web developer at - I DO NOT work for ChronoEngine!
Professional Work:
Custom CF / CC Plugins and Extensions:
CarmeloDev91 2
February 03 2020, 11:57 #391024
Thank you for reply! How I can put this code? In the datepicker? I don't understand how I can setting the form...