Validating required fields one page at a time in a multipage documents

New Here ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Hello,

I am a novice in javascript, so please bear with me. I have this pdf form which is 6 pages long. In every page, there are required text fields, checkboxes, radio buttons etc. In some cases, if the user check one box, then at least one box should be checked from multiple options. Then, some text fields are required if a particular checkbox is checked (as like attached figure). I want to validate required fields on each page before the user wants to go to next page (like provide them a pop-up message that these fields are left empty while they are required but do not want to force them to be on the page only) - the reason being not to validate the entire form at the end and browse back if anything left empty (that is the functionality I was told to bring; no choice for me in that). I was searching this amazing support community posts but couldn't find anything that suits my purpose. Can anyone offer any help please? BTW, I am using Adobe Acrobat Pro latest version. 

TOPICS
PDF forms

Views

107

Likes

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
Most Valuable Participant ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

You really can't control the user to that extent - and for many forms, really shouldn't try. Users fill paper forms in any order that suits them, as the information comes to hand. Then they may put it aside for minutes or days while looking for more answers. As a programmer I feel I should not be telling people how to do that. Looking at your form, that looks exactly the sort of way people would fill it: research and phone calls and outdoor clothes may be needed to get the answers.

 

That's not to say validation isn't important, but I believe it needs to be much more dynamic, and help rather than block people. For example, if a section doesn't make sense to fill in yet, keep it disabled and explain why it's disabled.

Likes

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
Adobe Community Professional ,
Apr 20, 2021 Apr 20, 2021

Copy link to clipboard

Copied

Hi,

 

As you want it per page, you are probably going to have to code it all,  it would probably not be a very difficult script and it would be able to be repeated for multiple pages. The script would be something like

 

if ( this.getField("checkbox").isBoxChecked(0))// would need to make sure this is the correct box
{
  var fieldToCheck1 = this.getField("fieldOne");
  if ( fieldToCheck1.value == "" ){
    app.alert ( "You have a incomplete field");
  }
}

 

This may need to be updated but without seeing the PDF file it is hard to make it more accurate, if you can provide this we can provide more accurate code, and based on you image it would be if multiple fields where all empty , this can be coded too. We could modify the above code to check the value of multiple fields and if they are all empty then raise the error.

 

This code could be placed behind a button on each page, therefore hte user coudl check each page as they go, but they can continue on to the next page without any problems.

Likes

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 ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

Sorry, the form cannot be uploaded as there is confidentiality issue. But the figure attached with the initial post give the summary of what I want to established. There are some text fields and checkboxes stand alone required. Also there are some boxes which become mandatory once another box is checked and it can be from multiple options (at least one is mandatory). When this one option is selected, two or more text fields become mandatory as shown in the figure. once again, sorry for not being able to post the entire form. Any help is appreciated!

Likes

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
Adobe Community Professional ,
Apr 21, 2021 Apr 21, 2021

Copy link to clipboard

Copied

LATEST

Hi,

 

Then you can use the code above to be placed behind a button on each page, when the user clicks the button you can run your code which can check each checkbox in turn, if the check box is checked then it can check each field in turn to check they have suitable values.

 

Once you have passed them all you can show a dialog to the user that there are fields that need filling in, or that this page is valid.

 

There would be no need to force the user to have to click the button, although it may be that you might want to encourage them to do so.

 

Without the form it is tough for me to expand on the sample code above as I don't know the field names, but you should be able to try something from the above code and if you get into trouble you can post the code with any errors here and we can try and help you.

Likes

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