Expand my Community achievements bar.

Changing a field color based on the answer

Avatar

Level 1

ok. I am looking to do a simple verification based on what someone enters into a text field, meaning there is a "correct" and "incorrect" response. I know how to do this with JavaScript on the web, but I am having trouble translating that into a PDF form. Below is what I would do on a website to get it to work:

function check() {

var i = document.getElementById('response');

if(i.value === 'correct')

{i.style.color = 'red'}

else

{i.style.color = 'black'}

};

I would then call the function on a button press. How would I translate this for a PDF Form. Any help would be GREATLY appreciated.

2 Replies

Avatar

Former Community Member

Hi,

You can use the following script, with RGB specs:

TextField1.border.fill.color.value = "196,196,196";

There are many other sections you can highlight and bold, etc... this will highlight the entire field.

have fun...

Avatar

Level 1

Thank you for the response! I do have a follow-up question. Does (document.getElementById) work within a PDF, or do I need to use an alternative?