Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How do I create an alert that pops up when submit his clicked but not all fields are complete?

New Here ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Hi! I know how to write an alert for a single field, but can't figure out how to make it work for several fields & check boxes in the submit button.  Here is my code for one field:

 

if (getField("Date").value=="") app.alert("Please complete the form before signing!", 0);

 

Thank you!

TOPICS
JavaScript, PDF forms

Views

149

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

correct answers 1 Correct answer

Adobe Community Professional , Jul 02, 2021 Jul 02, 2021
Download link works fine for me. When you set 'blank' as default, did you also change "" to " " in script regarding that field? Maybe also try in dropdown field, under 'options' tab check 'Commit selected value immediately'.

Likes

Translate

Translate
Adobe Community Professional ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Add other fields to comparison with these operators:

&& and

|| or

EXAMPLE:

if (getField("Date").value=="" || getField("Date2").value=="") Using 'or' operator will pop alert if any of those fields are empty.

While using 'and':

if (getField("Date").value=="" && getField("Date2").value=="") means alert will pop only if both fields are empty.

In your case I would go with 'or' operator.

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

When I type in the code below, it works for the "date" but not for the "vessel name". What am I missing?

Thank you!

 

if (getField("Date").value=="" || getField("Vessel Name").value=="") app.alert("Please complete the form before signing!", 3);

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Is it "vessel name" or "Vessel Name"?

Javascript is case sensitive.

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Vessel Name

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

When every field is complete, it unhides the digital signature but the alert still pops up

 

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Can you post your full code or  your file?

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

This is all I have for now. I have 32 check box fields to add.

 

if (getField("Date").value=="" || getField("Vessel Name").value=="") app.alert("Please complete the form before signing!", 3);

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Then check that field names in script and in your files are same.

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

They are the same.

 

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Where do you use script?

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

I'm using it in a button that says "click  here to sign". When every field is completed, the button will unhide the digital signature box. If something isn't complete, it won't unhide the box. However, I think when it doesn't unhide, the employee will think it's just not working. This is why I wanted an alert.

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

What code do you use to unhide signature field?

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

var bEmpty = "";
if(this.getField("Date").valueAsString == "" || this.getField("Vessel Name").valueAsString == "" || this.getField("Check Box 0").valueAsString == "Off"|| this.getField("Check Box 1").valueAsString == "Off" || this.getField("Check Box 2").valueAsString == "Off" || this.getField("Check Box 3").valueAsString == "Off" || this.getField("Check Box 4").valueAsString == "Off" || this.getField("Check Box 5").valueAsString == "Off" || this.getField("Check Box 6").valueAsString == "Off" || this.getField("Check Box 7").valueAsString == "Off" || this.getField("Check Box 8").valueAsString == "Off" || this.getField("Check Box 9").valueAsString == "Off" || this.getField("Check Box 10").valueAsString == "Off" || this.getField("Check Box 11").valueAsString == "Off" || this.getField("Check Box 12").valueAsString == "Off" || this.getField("Check Box 13").valueAsString == "Off"|| this.getField("Check Box 14").valueAsString == "Off" || this.getField("Check Box 15").valueAsString == "Off" || this.getField("Check Box 16").valueAsString == "Off" || this.getField("Check Box 17").valueAsString == "Off" || this.getField("Check Box 18").valueAsString == "Off" || this.getField("Check Box 19").valueAsString == "Off" || this.getField("Check Box 20").valueAsString == "Off" || this.getField("Check Box 21").valueAsString == "Off" || this.getField("Check Box 22").valueAsString == "Off" || this.getField("Check Box 23").valueAsString == "Off" || this.getField("Check Box 24").valueAsString == "Off" || this.getField("Check Box 25").valueAsString == "Off" || this.getField("Check Box 26").valueAsString == "Off" || this.getField("Check Box 27").valueAsString == "Off" || this.getField("Check Box 28").valueAsString == "Off" || this.getField("Check Box 29").valueAsString == "Off" || this.getField("Check Box 30").valueAsString == "Off" || this.getField("Check Box 31").valueAsString == "Off" || this.getField("Check Box 32").valueAsString == "Off")
var bEmpty = "true";
this.getField("Employee Name").display = bEmpty == "true" ? display.hidden : display.visible;

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Add this to the bottom of that code:

if(bEmpty == "true") app.alert("Please complete the form before signing!", 3);

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Ahhh ... I was getting close to that but not quite right. 

 

So, it works on every field but the "Vessel Name" field. This field is a dropdown. Is that the reason? 

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

It won't work with dropdown for "" if you added blank space as default value  then use like this " ".

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

I have a blank space set as default and it still isn't working. It won't unhide the signature if the vessel name field is blank with the script without the app alert script. When I add it in the script, it will unhide that field even if empty.

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Can you post your file here?

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 ,
Jul 01, 2021 Jul 01, 2021

Copy link to clipboard

Copied

Try this sample file:

https://drive.google.com/uc?export=download&id=18foTaunm1Vk-d_60moZPLXU7zKYTq4S_ 

I tried to recreate your file, so check if it works as you intended.

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 ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

Hi! I tried to open your link but it says "site can't be reached". I tried a few other things with no luck. I also deleted the dropdown list and created a new one with the blank space being the default setting. 

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 ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

Download link works fine for me.

When you set 'blank' as default, did you also change "" to " " in script regarding that field?

Maybe also try in dropdown field, under 'options' tab check 'Commit selected value immediately'.

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 ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

LATEST

HI, I discovered my error in the "" vs " " about 3 mintues after my last post. I just finished testing it with the signatures and email submission and it is all working great. Thank you so very much!!

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