Highlighted

Concatenate selections and populate new text field

New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

Hi all,

I have a fill-in form I am working on in Acrobat Pro DC. I have several list boxes and text fields that I am using the export value of the item to basically build a file name that displays in a separate text field, "FileName". On the text field "FileName" I am using a custom calculation script. I have this working fine but the value displays at all times and changes each time the user moves from one field to the next. I would rather have the field blank until all fields have been completed. Can anyone suggest how to do this? 

TOPICS
PDF forms

Views

64

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Concatenate selections and populate new text field

New Here ,
Sep 29, 2020

Copy link to clipboard

Copied

Hi all,

I have a fill-in form I am working on in Acrobat Pro DC. I have several list boxes and text fields that I am using the export value of the item to basically build a file name that displays in a separate text field, "FileName". On the text field "FileName" I am using a custom calculation script. I have this working fine but the value displays at all times and changes each time the user moves from one field to the next. I would rather have the field blank until all fields have been completed. Can anyone suggest how to do this? 

TOPICS
PDF forms

Views

65

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 29, 2020 0
Most Valuable Participant ,
Sep 29, 2020

Copy link to clipboard

Copied

You need to add a condition that makes sure all the other fields have a value before populating the text field.

For example:

var a = this.getField("A").valueAsString;

var b = this.getField("B").valueAsString;

var c = this.getField("C").valueAsString;

if (a!="" && b!="" && c!="") event.value = a + ", " + b + ", " + c;

else event.value = "";

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 29, 2020 0
New Here ,
Sep 30, 2020

Copy link to clipboard

Copied

try67,

Thank you so much for your reply, I have this working now thanks to your help. It took me a minute to figure out how to handle some of my fields that are list boxes with "Make a Selection" displaying as the default value. I set that export value to 0 and check that before the event. 

I do have one other question if I can trouble you? One of my field is a date field using the calendar popup. The date field name is Date2Mail. Would it be possible to check that the date selected by the user is at least 1 day after than the current date? Or, to get even fancier the ideal solution would be, if user selects same date as current or next date as current, display some alert text in a hidden field next to the date field on the form. I can then give some details to the user about time lines, etc. 

Thanks so much for your help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 30, 2020 0
try67 LATEST
Most Valuable Participant ,
Sep 30, 2020

Copy link to clipboard

Copied

You can use this code as the custom Validation script for that field (adjust the date pattern string if needed):

 

if (event.value) {
	var now = new Date();
	now.setHours(0);
	now.setMinutes(0);
	now.setSeconds(0);
	var d2 = util.scand("mm/dd/yyyy", event.value);
	d2.setDate(d2.getDate()-2);
	if (d2.getTime()<now.getTime()) {
		app.alert("You must enter a date that's at least one day after today.");
		event.rc = false;
	}
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 30, 2020 0