Expand my Community achievements bar.

Highlighting Fillable Sections in Adobe Experience Manager PDF Form

Avatar

Level 3

Hi community members,

 

I'm working on a PDF form in Adobe Experience Manager. Currently, I can highlight the entire object border when it's empty using code and subsequent output.

function highlightField(field) {
    field.borderColor = "255,0,0"; // Set border color to red
}

0experience_0-1698862379985.png

 

However, I'd like to focus on highlighting just the user-fillable part, like in the example below.

0experience_1-1698862408097.png

 

Any suggestions on code adjustments would be appreciated!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

9 Replies

Avatar

Level 3

I would use the nullTest property. This is usually set using Designer's UI in the Object Palette/Value Tab/Type: User Entered - Required.

You can either set the nullTest that way or with code on the initialize event: The code works better because it will look at the field and determine if it has a value or not. This is a good because if the user saves the form and re-opens it later the red border will not show for fields that already have a value.

if (this.rawValue == null)
{
this.validate.nullTest = "error";
}
else
{
this.validate.nullTest = "";
}

 

Then in the exit event you would put the same code so if the user enters a value you turn the red border off.

if (this.rawValue == null)
{
this.validate.nullTest = "error";
}
else
{
this.validate.nullTest = "";
}

I would do as you are doing it by creating a function and re-use the function on initialize and exit events.

 

Avatar

Level 3

Thank you for your response @koolForms  

 

I'd not prefer to use the "Required" option. This is because when the PDF form is opened, it displays a red border, which I'd like to avoid.

 

Ideally, I'd like the form to appear as it does the first time a user opens it. Then, at the end of the form, I have a button. When the user presses this button, it will check all the mandatory fields (kept in an array or through some other logic). If any required fields have not been filled or selected, I will use the function mentioned above to highlight them.

 

Now I can highlight the whole object using the function but not the fillable part as provided screenshot with the question. 

Avatar

Community Advisor

Use the below script code in the initialize event:

 

this.validate.nullTest = (this.rawValue) ? "" : "error";

Avatar

Level 3

Thanks @Vijay_Katoch 

 

I'd not prefer to use the "Required" option. This is because when the PDF form is opened, it displays a red border, which I'd like to avoid.

 

Ideally, I'd like the form to appear as it does the first time a user opens it. Then, at the end of the form, I have a button. When the user presses this button, it will check all the mandatory fields (kept in an array or through some other logic). If any required fields have not been filled or selected, I will use the function mentioned above to highlight them.

 

Now I can highlight the whole object using the function but not the fillable part as provided screenshot with the question. 

Avatar

Level 10

You can execute a script to disable the field highlighting of the PDF viewer. 

app.runtimeHighlight = false;

 

To create a border around the input area of a field use the following script as follows:

Textfeld1.ui.oneOfChild.border.edge.color.value = "255,0,0"; // Create a red border

 

Avatar

Level 3

@radzmar thanks for your reply, and suggestion. So I used your suggestion in my function 

function highlightField(field) {
  field.ui.oneOfChild.border.edge.color.value = "255,0,0"; // Create a red border
}

but it is not highlighting anything. Just want to mention that the `field` is a variable I am taking it in this way

 

var field = xfa.resolveNode(
    "full_path_of the_object"
  );

Avatar

Administrator

@0experience Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 3

@kautuk_sahni I appreciate your suggestions, but unfortunately, I didn't find them helpful in solving the problem. I also tried to find a solution on my own, but without success. Thank you for your assistance.

Avatar

Level 3

@kautuk_sahni can you move the post from discussion to question? I can accept a answer. Thanks