you can calculate dates much easier with FormCalc that with JavaScript.
if (not $.isNull) then
var cPattern = "DD.MM.YYYY" ;How the entered date is formatted
var cStartDate = $.formattedValue ;The entered anf formatted date
var iStartDate = Date2Num(cStartDate, cPattern) ;The date converted into an integer
var iNumMonths = 35 ;Months to count
var iNumSubtractDays = 7 ;Value to be subtracted later.
var iNumCount = 0 ;Month counter
;A while loop that executed as long the desired number of months have been counted
while (iNumCount lt iNumMonths) do
;If current month is different to previous month …
if (Num2Date(iStartDate, "M") ne Num2Date(iStartDate - 1, "M")) then
;…add 1 month to the counter
iNumCount = Sum(iNumCount + 1)
endif
;Add 1 day to the counter for the next iteration of the while loop
iStartDate = Sum(iStartDate, 1)
endwhile
;Show result in textfield etc.
Textfield = Num2Date(Sum(iStartDate, -1, iNumSubtractDays), cPattern)
endif
Add the script above into the exit event of you start date field and set the scripting language to FormCalc.