Highlighted

Required field alert upon submission

New Here ,
Sep 09, 2020

Copy link to clipboard

Copied

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

Views

72

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

Required field alert upon submission

New Here ,
Sep 09, 2020

Copy link to clipboard

Copied

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

Views

73

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
Sep 09, 2020 0
New Here ,
Sep 09, 2020

Copy link to clipboard

Copied

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"));

}

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
Reply
Loading...
Sep 09, 2020 0
Most Valuable Participant ,
Sep 09, 2020

Copy link to clipboard

Copied

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"});

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
Reply
Loading...
Sep 09, 2020 0
New Here ,
Sep 09, 2020

Copy link to clipboard

Copied

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?

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
Reply
Loading...
Sep 09, 2020 0
Most Valuable Participant ,
Sep 09, 2020

Copy link to clipboard

Copied

Yes.

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
Reply
Loading...
Sep 09, 2020 0
New Here ,
Sep 09, 2020

Copy link to clipboard

Copied

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?

 

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
Reply
Loading...
Sep 09, 2020 0
Most Valuable Participant ,
Sep 09, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 09, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Also, how do I reset the form?

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

Tools - Prepare Form - More - Clear Form.

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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?

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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?

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

To clear the field you can use this code:

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

Or even:

this.resetForm(["grant"]);

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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?

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

Where did you place the code?

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

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.

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 10, 2020

Copy link to clipboard

Copied

Check the JS Console after clicking one of those check-boxes...

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
Reply
Loading...
Sep 10, 2020 0
New Here ,
Sep 10, 2020

Copy link to clipboard

Copied

Okay,

I've spent hours trying to figure out why the grant field will not validate. I looked at the JavaScript I'm not sure what I'm even looking for. I erased every reference in the JavaScript that referenced the grant field and not to work. Even when it was erased some of the commands still worked. Not sure why that happened. Any suggestions would be greatly appreciated. I am so close to getting this exactly how I need it.

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
Reply
Loading...
Sep 10, 2020 0
Most Valuable Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

This is the error message I'm getting:

 

TypeError: this.getField("grayimage") is null
16:Field:Mouse Up

 

It happens because there's no field with that name, and it causes the rest of the code to not work.

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
Reply
Loading...
Sep 11, 2020 0