Date Calculation in LiveCycle Designer ES4

saugata74

03-10-2017

Hi,

I have created a form comprising of two Date fields, date_required and date_implemented. Now, there is a validation check on date_implemented field. It is that the date_implemented field can accept dates that are 10 days after the date_required field. Else error will be displayed and focus should be on date_implemented field. Also, the form cannot be saved till all validations in the form are successfully passed. Further, there is a Days field that displays number of days elapsed between date_required and date_implemented. Please provide with requisite code both in JavaSript and FormCalc.

Rgds,

S Banerjee

Accepted Solutions (0)

Answers (1)

Answers (1)

radzmar

MVP

05-10-2017

On the exit event of date_implemented add the following FormCalc script.

var datePattern = "MM/DD/YYYY"

if (Date2Num($.formattedValue, datePattern) - Date2Num(date_required.formattedValue, datePattern) gt 10) then

    $host.messageBox("Warning massage …")

    $ = null

    $host.setFocus($.somExpression)

endif

Keep in mind, that you cannot suppress saving a form in any case.