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

Required field alert upon submission

New Here ,
Sep 09, 2020 Sep 09, 2020

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.

TOPICS
PDF forms
6.3K
Translate
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 ,
Sep 09, 2020 Sep 09, 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"));

}

Translate
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 ,
Sep 09, 2020 Sep 09, 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"});

Translate
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 ,
Sep 09, 2020 Sep 09, 2020

Thank you. When I use the submit form button you have an export format option. I opted to export PDF. Will the above code do the same thing?

Translate
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 ,
Sep 09, 2020 Sep 09, 2020

Yes.

Translate
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 ,
Sep 09, 2020 Sep 09, 2020

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?

 

Translate
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 ,
Sep 09, 2020 Sep 09, 2020

It's whether or not the email is sent silently (if there's no UI -- User Interface -- it's sent silently), but you can't set it as false unless you can install a script on the local computer of each user, and even then it won't be completely silent.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

It is not checking to see if my radio buttons are required, so I tried adding to the code but it didn't work. Here's what I did

 


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") || (f.type=="radio" && 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"));

}

else this.mailDoc({cTo: "sample@sample.org"});

what am I doing wrong

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

This is an outdated version fo the code. Change this line:

if ((f.type=="text" && f.value=="") || (f.type=="checkbox" && f.value=="Off") || (f.type=="radio" && f.value=="Off"))

To:

if (f.defaultValue==f.valueAsString)

And it will work with any field type.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Thanks. My radio buttons are still not showing up in my warning message.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Strange. Are they set as required? Can you share the file with us if so?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

I am sure it's something I did. There's a lot going on and I'm sure I did something that is conflicting with this issue. I shared the file above.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

For some reason (my guess is it's because it was created with InDesign) the value of this field is currently "false", instead of "Off". Reset the form, save it and then try again.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

If you go to the radio button under donationgrant and look at the actions for charitable donations you will see the custom script I added. Maybe something there is causing the problem. I do have a bunch of values changed. And I do have some value set to false and off.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

If that is the problem do I just change the word false to off

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Can you set the default value in InDesign? If so, that's bad... It should be set to "Off" to work properly in Acrobat.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Also, how do I reset the form?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Tools - Prepare Form - More - Clear Form.

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

In my custom actions in Adobe I edited the following code:
this.getField("grant").value= false;

should I be using off instead of false? If so how do I that?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

I did not know about clearing the form. That worked!

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

I spoke too soon. It works but if I change options, then it does not. I'm sure it has to do with the off versus false. How do I change the value in the code from false to off?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

To clear the field you can use this code:

this.getField("grant").value= "Off";

Or even:

this.resetForm(["grant"]);

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

I am almost there. I've got my cost center radio but in working, but not my grant radio button. Below is the code I use for my custom actions. I know this is causing the issue but I can't figure out why.

this.getField("grant").required = false;
this.getField("grant").readonly = true;
this.resetForm(["grant"]);
this.getField("Cost Center").value= "Off";
this.getField("customeracct").required = false;
this.getField("customeracct").readonly = true;
this.getField("customeracct").fillColor = ["RGB",.66,.66,.66];
this.getField("grant").fillColor = ["RGB", .6688, .66, .66];


if(event.target.value == "CHARITABLE DONATION") {
this.getField("charitabledonation1").value="On";
this.getField("charitabledonation2").value="On";
this.getField("charitabledonation1").fillColor = ["RGB", 1, 1, 1];
this.getField("charitabledonation2").fillColor = ["RGB", 1, 1, 1];
this.getField("grayimage").display = display.hidden;
this.getField("graysquare").display = display.visible;
this.getField("marketing").setFocus();
this.getField("customeracct").readonly = true;
this.getField("customeracct").required = false;
this.getField("customeracct").fillColor = ["RGB",.66,.66,.66];
this.getField("customeracct").fillColor = ["RGB",.66,.66,.66];
this.getField("grant").fillColor = ["RGB", .6688, .66, .66];
this.getField("grant").required = false;
this.getField("Cost Center").required = true;
this.getField("grant").value= "Off";
this.getField("grant").readonly = true;
}

if(event.target.value == "GRANTPROMOTION") {
this.getField("Cost Center").required = true;
this.getField("charitabledonation1").value="Off";
this.getField("charitabledonation2").value="Off";
this.getField("charitabledonation1").fillColor = ["RGB",.66,.66,.66];
this.getField("charitabledonation2").fillColor = ["RGB",.66,.66,.66];
this.getField("customeracct").fillColor = ["RGB", 1, 1, 1];
this.getField("grant").fillColor = ["RGB", 1, 1, 1];
this.getField("customeracct").required = true;
this.getField("customeracct").readonly = false;
this.getField("grant").required = true;
this.getField("grant").readonly = false;
this.getField("grayimage").display = display.visible;
this.getField("grayimage").readonly = true;
this.getField("graysquare").display = display.hidden;
}



do you see where my mistake is?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

Where did you place the code?

Translate
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 ,
Sep 10, 2020 Sep 10, 2020

In the top right hand corner of the form you have to choose between charitable donation and grant/promotion . I placed all of that code in the actions.

Essentially if charitable donations is selected you do not need to answer the radio buttons on the right-hand side (choose GL account) but if you select grant/promotion then you have to.

Translate
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