Skip to main content
Participant
March 16, 2024
Answered

Different date formats on multiple pages

  • March 16, 2024
  • 2 replies
  • 1421 views

I have a form I'm creating with a date on page 1 ex: 03/16/24 and am trying use the same Text Field name on page 3 but only output the "03" in the date as March.  I've tried different scripts that i have found on this forum but can't get it to work as I am a complete newbie :). 

This topic has been closed for replies.
Correct answer try67

Almost working, when I use that code I am now able to get different output formats, but when I use a custom format under category Date as "dd" I get a blank, if I use "mmmm" I will get March.  I need to solve for "dd".  Thanks for your help.


That's because "dd" is not considered a valid Date. Set the field's format to None and use this code as its custom calculation script:

 

var s = this.getField("Text1").valueAsString;
if (s=="") event.value = "";
else event.value = util.scand("mm/dd/yyyy", s).getDate();

2 replies

Participant
March 16, 2024

I was reading in another post from a few years ago, if you created a script on another Text Field name referencing the the 1st one, that it is indeed possible.  I'm just too new at scripts to understand how.

try67
Community Expert
Community Expert
March 16, 2024

Yes, that is correct. If the first field is named "Text1" and the second field is named "Text2", for example, use this code as the custom Calculation script of the latter:

event.value = this.getField("Text1").value;

Then you would be able to set its Format setting to something else.

Participant
March 17, 2024

Almost working, when I use that code I am now able to get different output formats, but when I use a custom format under category Date as "dd" I get a blank, if I use "mmmm" I will get March.  I need to solve for "dd".  Thanks for your help.

try67
Community Expert
Community Expert
March 16, 2024

It's not possible if they have the same name.