Copy link to clipboard
Copied
Hello,
New to Adobe and couldn't find the answer on this forum....
I would like to have a hidden text field (or button) to show up on a pdf fillable form if the user fails to complete every required field for the purpose of letting the receipient know upon opening the pdf after receiving via email that a required field is missing.
The hidden text/button field feature would not be visible on a blank form (no data entered into any fields), but once a user completes one field and tabs out (or clicks out of the field), the hidden text/button feature would display on the top of the form alerting both user and recipient that at least one required field is missing.
The hidden text/button feature would only dissapear once all required fields are filled in (or all fields are blank).
Of note, the form has numerous text fields, check boxes, radio buttons, and a signature field.
Thank you for any assistance you can provide.
Copy link to clipboard
Copied
Try this code:
var allFieldsEmpty = true;
var emptyRequiredFields = false;
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button") {
if (f.required && f.valueAsString==f.defaultValue)
emptyRequiredFields = true;
if (f.valueAsString!=f.defaultValue)
allFieldsEmpty = false;
}
}
if (allFieldsEmpty) event.target.display = display.hidden;
else event.target.display = emptyRequiredFields ? display.visible : display.hidden;
Copy link to clipboard
Copied
Create the field in question and then apply this code as its custom calculation script:
var emptyFields = false
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields = true;
break;
}
}
event.target.display = emptyFields ? display.visible : display.hidden;
Copy link to clipboard
Copied
Hello,
I created a new Text Field and added the provided code to the "custom calculation script" section. Yes, the new text field was hidden and then appears after I tab out of the first field I complete. However, not every field (text, checkbox, radio, and signature) is required to be completed. What do I add to the code to identify what are the required fields? Thanks.
Copy link to clipboard
Copied
I figured it out. I needed to check the box for each required field.
Copy link to clipboard
Copied
Hello,
The only issue I seem to have is that the Hidden Text Field is automatically viewable when the form is opened (because not every required field is completed yet). Is there a way to have the Hidden Text Field stay hidden when opening the file (all fields are still blank) until after text is entered into the first field and the user tabs out or click out of that first field? Thanks.
Copy link to clipboard
Copied
Try this code:
var allFieldsEmpty = true;
var emptyRequiredFields = false;
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button") {
if (f.required && f.valueAsString==f.defaultValue)
emptyRequiredFields = true;
if (f.valueAsString!=f.defaultValue)
allFieldsEmpty = false;
}
}
if (allFieldsEmpty) event.target.display = display.hidden;
else event.target.display = emptyRequiredFields ? display.visible : display.hidden;
Copy link to clipboard
Copied
That worked! Thanks! Also, is it possible in Adobe to do the following:
- The "required" fields automatically show a red colored line box around them? Is there a way to:
- On a blank form (no inputs are filled in yet), to not show the red-colored boxes?
- Once a "required" field is completed with input (and tabbed out of or clicked out of), to have the red-colored box dissapear?
- Seperately, I have a section on the form with 5 check boxes. At least one of the 5 needs to be checked by the user. There are occassions that a user might check multiple (not all) checkboxes. Is there a way to set a "required" rule to the group of 5 boxes that states at least 1 box must be checked, otherwise the previous Hidden Text Field will display?
Thank you.
Copy link to clipboard
Copied
1. Yes, but it will require a much more complex script that will need to show/hide the fields border color as well as fill color.
2. Yes, but also using a more complex, custom-made script to test a group of fields, instead of individual ones.
I've developed both of these scripts for my clients in the past, so if you're interested in hiring a professional developer to do it for you, feel free to contact me privately via a PM to discuss it further.
Copy link to clipboard
Copied
Okay, thanks a lot. I'll see if my office wants to proceed and will contact you if needed. Thank you!
Copy link to clipboard
Copied
Is there a way for this field to indicate/list the names of the fields that have been missed? Really what I'm looking for is a quick indication to the person filling out the form that they have missed some fields. There are some that we can make required to not make submission possible, but we'd like to have something that could visually identify some fields they may have accidentally scrolled past/missed.

