Change form field background colour if the field is not filled out or is left blank?

New Here ,
Jun 22, 2018

Copy link to clipboard

Copied

I am creating a bracket style form pdf. each bracket will have a form field to add a name but there will be instances the bracket needs to be left blank due to the rotation of people. is there a way to either fill a field in with "Blank" or leave it blank that the background color changes to black? Picture enclosed of my bracket example. Screen Shot 2018-06-22 at 11.19.40 AM.png

TOPICS
Acrobat SDK and JavaScript

Views

352

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 22, 2018

Copy link to clipboard

Copied

Both are possible. Which one do you prefer? If you want to change the field's fill color then you have to disable the highlight color, though.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I would really like to make the box all black if there is no info to put into that field. Any suggestions on how I go about doing this? Thanks.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 22, 2018

Copy link to clipboard

Copied

When should it change, then? If the field is black when the user clicks into it they won't be able to see what they're typing...

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I want it to change if the user does not fill the field out or an option is if they type the word "BLANK" the box changes to black.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jun 23, 2018

Copy link to clipboard

Copied

You didn't really answer my question, but OK... Here's how I would do it.

Set the field's fill color to black, and apply this code as the field's On Focus script:

event.target.fillColor = color.white;

And this code as its Validation script:

event.target.fillColor = (event.value=="" || event.value=="BLANK") ? color.black : color.white;

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Sorry I am not just getting back into this project.

To Clarify because my original question/comments were vague. I want the box to remain white fill/black outline as you can see in the first picture I posted. I would like the box to change to a fill of black should the person type the word "BYE" into the field. Does this make better sense? Thanks for the help.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jul 18, 2018

Copy link to clipboard

Copied

You can use the code I provided before, just change "BLANK" to "BYE" in the code.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Thanks again for all the help, but i have 1 more question. I was able to get the box to change to black, so thats awesome! Is there a way for me to change the type in that black box to be white when BYE is entered?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Most Valuable Participant ,
Jul 20, 2018

Copy link to clipboard

Copied

Yes, like this:

event.target.textColor = (event.value=="" || event.value=="BYE") ? color.white : color.black;

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
nickigibby AUTHOR LATEST
New Here ,
Jul 20, 2018

Copy link to clipboard

Copied

You are my lifesaver! Thank you so much for your patience and all of your help!

Likes

Translate

Translate

Report

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