Skip to main content
Known Participant
September 9, 2020
Question

Required field alert upon submission

  • September 9, 2020
  • 1 reply
  • 6001 views

I have set several fields in my form to required. If the field is not completed upon submission the Adobe acrobat error message appears stating that at least one field is empty.

Is there a way to specify which fields are empty? Specify a list of empty fields the user needs to go back and complete? Instead of just a general statement.

If so how would I go about doing that? This is my 1st form I am completing.

This topic has been closed for replies.

1 reply

Known Participant
September 9, 2020

Okay, I was able to find the following script and it works, but 1st I get the default general warning saying 1 of the required fields is not complete. Followed by a 2nd warning displaying exactly which fields need to be filled in.

How do I remove the 1st warning?

Here is the script I used by placing it in the actions for the submit button.

var emptyFields = [];

for (var i=0; i<this.numFields; i++) {

var f= this.getField(this.getNthFieldName(i));

if (f.type!="button" && f.required ) {

if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off")) emptyFields.push(f.name);

}

}

if (emptyFields.length>0) {

app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));

}

try67
Community Expert
September 9, 2020

You have to use only the JS action, not both JS and Submit Form.

Add the following to the end of the script (use the actual email address to submit it to, of course):

 

else this.mailDoc({cTo: "me@server.com"});

Known Participant
September 9, 2020

Yes.


Thank you again, but I have one more follow-up question.
With the code this.mailDoc({cTo: "me@server.com"});


I have seen where people add true and false to it. For example:
this.mailDoc(true, "yourname@address.com")

I found something that said the true and false refers to bUI, but what is that?