Copy link to clipboard
Copied
I am working in Acrobat DC.
I have a multipage form, on the first page I have three text fields for a person’s name: FirstName, MiddleName, and LastName. On one of the pages that follows, I have a text field, FullName, that combines the three previous fields together. This is the coding I have for that and it is working:
if (this.getField("MiddleName").valueAsString==""){ //if there is no middle name
event.value = this.getField("FirstName").valueAsString + " " + this.getField("LastName").valueAsString; //combines first and last name
}
else{
event.value = this.getField("FirstName").valueAsString + " " + this.getField("MiddleName").valueAsString + " " + this.getField("LastName").valueAsString;
//if there is a middle name, combines first, middle, and last name
}
I have a check box, Check Box46, in front of the FullName text field that I would like checked if there is a name in the FullName text field and unchecked if there is no name in the FullName text field.
I have found coding that if a box is checked/unchecked, text will appear/not appear, but I can’t seem to alter it so that it will work for my situation.
Thanks for your assistance, Jamie
Copy link to clipboard
Copied
Use this as 'Validation' script of "FullName" field:
this.getField("Check Box46").checkThisBox(0,event.value == "" ? false : true);
Copy link to clipboard
Copied
Hi Nesa, thank you so much for the line of code.
I placed the coding into the Validation area in the FullName field. When I enter a name into the FirstName field and tab out of that fieled the check box becomes checked, which is great; but if I delete the text that is in the FirstName field, the check box remains checked. What can I do in the coding to have the check box uncheck if there was an input error and the name needs to be deleted?
Copy link to clipboard
Copied
If the FullName field has value, checkbox will be checked, if FullName field is empty checkbox will be unchecked, so it's probably a problem how you set up your script to populate FullName from FirstName field, you need to set it to empty FullName field if FirstName is empty. What script did you use to populate FullName field?
Copy link to clipboard
Copied
Hi Nesa, in the Custom calculation script of the FullName field the script is:
if (this.getField("MiddleName").valueAsString==""){ //if there is no middle name
event.value = this.getField("FirstName").valueAsString + " " + this.getField("LastName").valueAsString; //combines first and last name
}
else{
event.value = this.getField("FirstName").valueAsString + " " + this.getField("MiddleName").valueAsString + " " + this.getField("LastName").valueAsString;
//combines first, middle, and last name
}