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

Required fields in fillable .pdf

New Here ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

I have a form that was created in InDesign that we are saving as a fillable .pdf. There are different required fields thru out the form. Is there any way to stop the form from being saved or submitted if all the required fields are not completed?

TOPICS
PDF forms

Views

360

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 ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

You can't stop the save of the form. You can only display a message when not all required fields are filled.

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 ,
Aug 12, 2024 Aug 12, 2024

Copy link to clipboard

Copied

How would I go about creating this error message for grouped checked boxes? I found a way to do it if the textbox isnt completed but I also need it for grouped questions where only one selection is needed. I have this code, that gives an error when the text box isn't completed but it won't give the error when only the checked boxes are skipped over. 

function validateFormFields() {
// Define required text fields (if any)
var requiredTextFields = ["TextField1"]; // Replace with actual text field names

// Define groups of checkboxes where at least one must be checked
var checkboxGroups = [
["CheckboxGroup1_Option1", "CheckboxGroup1_Option2"], // Group 1: At least one must be checked
];

var allTextFieldsValid = true;
var allCheckboxGroupsValid = true;
var invalidMessage = "";

// Check individually required text fields
for (var i = 0; i < requiredTextFields.length; i++) {
var fieldName = requiredTextFields[i];
var field = this.getField(fieldName);

if (!field || field.value.trim() === "") {
allTextFieldsValid = false;
invalidMessage += "Please complete all required text fields.\n";
// Note: Do not break here so we can check all fields and all checkbox groups
}
}

// Check checkbox group requirements
for (var j = 0; j < checkboxGroups.length; j++) {
var group = checkboxGroups[j];
var groupValid = false;

for (var k = 0; k < group.length; k++) {
var checkboxName = group[k];
var checkbox = this.getField(checkboxName);

// Check if checkbox is checked
if (checkbox && checkbox.value !== "Off") {
groupValid = true;
break; // Exit loop if at least one checkbox in the group is checked
}
}

if (!groupValid) {
allCheckboxGroupsValid = false;
invalidMessage += "Please select at least one checkbox in each required group.\n";
// Note: Do not break here so we can continue checking other groups
}
}

if (!allTextFieldsValid || !allCheckboxGroupsValid) {
app.alert(invalidMessage);
return false; // Prevent saving if any validation fails
}

return true; // Allow saving if all validations pass
}

// Add the save event trigger
this.setAction("WillSave", "if (!validateFormFields()) { event.rc = false; }");

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

The error message about the check-boxes appears fine for me. However, it's not set up very well.

For example, if you have multiple missing text fields you'll get the same line over and over. Same for the check-boxes. It's better to include the actual field name (or description) in the error message, and only show the title text once.

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

PS. The last line should not be a part of your code. It only needs to be used once.

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Thank you for the help! I was able to make the corrections you recommended and the code is working. The final issue I'm now having is that it seems the code isn't reading when the signature fields are completed.  I've filled in these fields but the error message still shows. Is this due to the field being a signature field and not a textbox? If it is, is there a better command to use to confirm these signature fields are completed? 

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

For signature fields you need to check that their value is not null.

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Would something like this work? It seems to not give an error message when the field is blank. I should also point out that some people are filling in these signature boxes with the fill and sign function and not by typing their names. Is there a way to capture this as well? 

if (field && field.type === "signature") {
if (field.signatureValue === null) {
invalidMessage += "Please complete the signature field: " + textField + ".\n"; }
} else if (field && (typeof field.value === 'string' && field.value.trim() === "")) { invalidMessage += "Please complete the text field: " + textField + ".\n"; }

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

There's no such property as "signatureValue". Use "value".

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

will this also work when someone signs the form using the fill and sign function that just overlays on top of the signature box? 

 

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

No, that's a different kind of signature.

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 ,
Aug 13, 2024 Aug 13, 2024

Copy link to clipboard

Copied

Is there a way to check for those signature types?

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 ,
Aug 14, 2024 Aug 14, 2024

Copy link to clipboard

Copied

LATEST

Yes, but it's a completely different code, as they are not really fields at all, but comments (I believe, it might have changed since I last looked into it).

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 ,
Nov 06, 2020 Nov 06, 2020

Copy link to clipboard

Copied

While you can't stop the form from being saved (or printed), you can force the saved copy to be blank.

You would need to use a script to do that, like this (paid-for) tool I've created:

http://try67.blogspot.com/2011/12/acrobat-validate-fields-before-printing.html

You can also get it from my new web-site, where's there's currently a "soft launch" sale:

https://www.try67.com/tool/acrobat-validate-required-fields-before-printing-or-saving

The discount code is available on the front-page.

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