How do I enforce required fields?

I want to make certain fields in my form to be required. I want them to be required so they cannot move from one field to the next if the field has not been filled in.

I found some javascript on the Adobe Acrobat 8 Developers Tips and the message pops up that says the field is required, but when you click ok - the message will not go away so that you can fill in the field. Here is the script - I am not very familiar with javascript.

//Optional Message - Comment out the next line to remove
app.alert("This field is required.Please enter a value.")

Jeanne Ullmer

4 Answers

Voted Best Answer

I full second Michael Kazlow's comment about forcing an answer before continuing to the next question. In fact, unless the next question really depends on the answer of the question, it is rather bad practice to not let the user out of a question.

It is better practice to not allow for subsequent actions (such as submitting data) if there are unanswered questions. But then, even saving should not be prevented if the answers are not complete; it is OK to display a warning, but that's sufficient.

Also, if there are reasons to force the user to answer before continuing, there must be the option "no answer" or "pause" or "not applicable", allowing the user to leave the field. What exactly should be done depends on the result of a careful analysis of the process represented by the form.

By Max Wyss   

I will let someone who has better knowledge of scripting help you with a better script, but you cannot enforce required fields. The best thing to do is to create a script that checks to see if fields have been left blank before the pdf file is submitted if that is how you are going to retrieve the data in the file.

I understand the desire for control. I cannot tell you how many surveys I have not finished, because the creator of the survey insisted that every question had an answer before continuing. Do you really want to insist every question is answered or do you want your users to fill out the form. Personally, I'd recommend the latter.

Michael Kazlow   

You may see this very useful:

Camilo Cumana   

Yes, you are right.

The right link could be this, at the end:

Camilo Cumana   

Please specify a reason: