Script for Dependant Visual Status
Hi All - really hoping someone can help me out with their JavaScript knowhow!
I‘m creating a PDF form for my team which will be used to record the results of testing. What I’d like to do is have a text field which will change its text value and text colour, depending on the value inputted into another field.
I have a text field in which a user will copy and paste a value which they have acquired - in this case it will be a hash value. There are expected reference hash values, and those acquired by the user during tests should ideally match these, but of course they may not. I want confirmation and a strong visual indication of this using a calculation script.
As an example:
I have a text field which the user will paste their acquired hash value into; this can either be upper-case or lower-case - we’ll call this field ‘Acquired-Hash’.
For ease, let us pretend for this example that the expected value is “3bf5”.
Next to the field ‘Acquired-Hash‘, I’d like a dynamic text field (called ‘Result’) which will automatically display the following:
If the ‘Acquired-Hash’ field is left blank, the ‘Result’ field will display “Awaiting Input” in BLACK lettering.
If the ‘Acquired-Hash’ field value is “3bf5” OR “3BF5”, the ‘Result’ field will display “MATCH” in GREEN lettering.
If the ‘Acquired-Hash’ field has a value of anything other than “3bf5” or “3BF5” entered into it, the ‘Result’ field will display “MIS-MATCH” in RED lettering.
Now, I have actually managed to achieve this using custom calculation scripts, but this is by having 3 separate ‘Result’ fields, with different default values, laid on top of each other - each one having a calculation script which affects their visibility depending on the entry into the ‘Acquired-Hash’ field. Although this works, it’s a bit clunky and time consuming to do in Acrobat, because I have multiple sections of the form where I will need to configure this validation of an inputted result.
Is there a way I can just have one ‘Result’ field with a single custom calculation script that will display the values as described above in the different colours, depending on the entry into the neighbouring ‘Acquired-Hash’ field? I’m building in InDesign, so this would save me so much time only having to create one Result field for each section of the form!
Many thanks in advance!
