• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Jun 22, 2018 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

2.0K

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
community guidelines
Community Expert ,
Jun 22, 2018 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.

Votes

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
community guidelines
New Here ,
Jun 22, 2018 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.

Votes

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
community guidelines
Community Expert ,
Jun 22, 2018 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...

Votes

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
community guidelines
New Here ,
Jun 22, 2018 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.

Votes

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
community guidelines
Community Expert ,
Jun 23, 2018 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;

Votes

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
community guidelines
New Here ,
Jul 18, 2018 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.

Votes

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
community guidelines
Community Expert ,
Jul 18, 2018 Jul 18, 2018

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
Jul 20, 2018 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?

Votes

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
community guidelines
Community Expert ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

Yes, like this:

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

Votes

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
community guidelines
New Here ,
Jul 20, 2018 Jul 20, 2018

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
May 20, 2022 May 20, 2022

Copy link to clipboard

Copied

LATEST

Is there a way to only highlight the cell when there's text entered - but when it's left blank, it stays white?

 

Votes

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
community guidelines