Skip to main content
vossliec
Participant
June 16, 2017
Pregunta

Keep auto fill date from updating once data is entered

  • June 16, 2017
  • 1 respuesta
  • 1084 visualizaciones

I added JavaScript to auto fill Today's Date but would like to know if the date the form was filled out can be saved once the form is filled out without updating to Today's Date each time the form is opened after it's been saved with data entered.  Thank you

Este tema ha sido cerrado para respuestas.

1 respuesta

Inspiring
June 16, 2017

This get tricky since one has to save the file with the date field empty or the property of the field you are testing needs to be clear.

I would guess you have a script similar to the following for auto filling the a date field:

this.getField("DateField").value = util.printd("d-mmm-yyyy", new Date());

One could add an if statement to see if the field is empty or not prior to executing the above line. Unfortunately it can be difficult to clear the value from the field.

Another approach would be to test the "defaultValue" of the field and if that value is empty, then set the value of the field and the defaultValue of the field. One can easily access the defaultValue of the field in the Prepare Form mode to clear the value. Your script could become:

if(this.getField("DateField").defaultValue == "")

{

this.getField("DateField").value = this.getField("DateField").defaultValue = util.printd("d-mmm-yyyy", new Date());

}