Avatar

Level 10

Hi Bibhu,

There are two problems trying to implement this:

  • Preventing the script that calculates the current date, from firing when the form is reopened. This script is probably in the docReady event of the current date field.
  • If the form is reopened and the user enters with the field that has the script to set the form data input date then this script will fire again, changing the date.

I think your best option is to have two readOnly date fields, currentDate (visible initially) and dataInputDate (hidden). These fields would be directly aligned one on top of the other.

Then in the field that you select as triggering the setting of the date that makes when the user input data you would hide the currentDate and show the dataInputDate. Example in the exit event

if (this.rawValue !== null)

{

     currentDate.presence = "hidden";

     dataInputDate.presence = "visible";

     //... set the date for the dataInputDate

}

else

{

     currentDate.presence = "visible";

     dataInputDate.presence = "hidden";

     dataInputDate.rawValue = null;

}

Make sure the preserve script changes is ticked in the File > Form Properties > Defaults tab.

As I say, if this field is re-entered and exited again at any stage then the script will re-fire and change the date.

Hope that helps,

Niall