Skip to main content
Inspiring
February 10, 2023
Answered

insert text between two numbers

  • February 10, 2023
  • 1 reply
  • 635 views

Hi
i have two fields.
1) "YEAR OF CONSTRUCTION"
2) "DESCRIPTION"
In field options 1) I flagged Comb of 4 characters.
For example 0311
In field 2) I have inserted this customized calculation script;
event.value="year of construction "+this.getField("YEAR OF CONSTRUCTION").value;
The text looks like this: "year of construction 0311"
I would like it to look like this: "year of construction 03/11"
I didn't use the mm/yy date format because the "/" already exists in the pdf file.
Please, can someone help me ?
Thank you

This topic has been closed for replies.
Correct answer try67

You can use this:

 

var year = this.getField("YEAR OF CONSTRUCTION").valueAsString;
if (year!="")
	event.value= "year of construction " + year.substring(0,2) + "/" + year.substring(2,4);
else event.value = "";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 10, 2023

You can use this:

 

var year = this.getField("YEAR OF CONSTRUCTION").valueAsString;
if (year!="")
	event.value= "year of construction " + year.substring(0,2) + "/" + year.substring(2,4);
else event.value = "";
ENE5CD9Author
Inspiring
February 10, 2023

Thank you