blank selection for dropdown

Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

I have a drop down that is required. but I do not want to have a selection pre chosen. I want to see it empty when first opening the form.

but when I do that, it accepts the blank as a choice.

I want to set the field as required but and force user to make a choice.

TOPICS
PDF forms

Views

5.1K

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

Community Expert , Jan 11, 2019 Jan 11, 2019

Use this:

if (this.getField("typeofestablishment").valueAsString=="click for more options") {

    app.alert("Please select a valid Choice Number 5");

} else if (this.getField("typeoflossortheft").valueAsString=="click for more options")  {

    app.alert("Please select a valid Choice Number 6");

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

Likes

Translate

Translate
LEGEND ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

If you use the UI then you enter a space. You can only add an empty or null string usong JavaSript.

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
Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

UI, you meant the form field properties....I tried that and it accepts it. I do not want it to accept a blank.

How to do this, which is not clear

Uou can pnlu add an empty or null string usong JavaSript.

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
Community Expert ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

You can add an empty string as the default value using a script, like this:

this.getField("Dropdown1").setItems(["", "Item 1", "Item 2", "Item 3"]);

I'm not sure if it will cause the required fields validation to fail, though, if that empty item is selected.

If it doesn't then you will also need to perform that validation using a script. I've posted similar scripts here in the past. Try searching for "validate required fields".

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
Participant ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

Being new at JS still, I may have mis spoke. I am trying to learn ad do stuff on my own, but holy JS is not easy.

I need a script that will check 2 dropdowns to make sure a choice was made. There is a default of 'click for more options'.

So my script checks to see if click for more options was chosen, if so it generates an error message......but then still emails the form.

I need to get the email submit in the script, not sure how.

This is what I have. I tried using and AND/OR but it did not work.

if (this.getField("typeofestablishment").valueAsString=="click for more options") { 

         app.alert("Please select a valid Choice Number 5"); 

     }

else if (this.getField("typeoflossortheft").valueAsString=="click for more options")  {

app.alert("Please select a valid Choice Number 6");

}

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
Community Expert ,
Jan 11, 2019 Jan 11, 2019

Copy link to clipboard

Copied

Use this:

if (this.getField("typeofestablishment").valueAsString=="click for more options") {

    app.alert("Please select a valid Choice Number 5");

} else if (this.getField("typeoflossortheft").valueAsString=="click for more options")  {

    app.alert("Please select a valid Choice Number 6");

} 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
community guidelines
New Here ,
May 30, 2020 May 30, 2020

Copy link to clipboard

Copied

May I ask where to put the JavaScript?

 

 

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
Community Expert ,
May 30, 2020 May 30, 2020

Copy link to clipboard

Copied

As the Mouse Up event of your submit button.

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

I know this is old, but I haven't seen anyone put the correct and easy way to do this anywhere. Putting it here in case anyone else runs into this issue.

 

After adding dropdown items in Item List, if you want the default to stay blank, simply click the white space under the different items in Item List. Done.

 

Hope this helps whoever runs into the same issue.

 

-69butthead69

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
Enthusiast ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

And what when that list is filled with more then 7 items  and white space is gone, it will only work if you have like 1-6 items.

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

Command-click the selected dropdown item. It will become unselected, and the field will become blank.

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 ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

That's in "edit fields"/"properties"/"options", by the way.

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
Enthusiast ,
May 11, 2022 May 11, 2022

Copy link to clipboard

Copied

What would be that on windows, because i clicked while pressing  using CTRL, SHIFT and ALT none of them 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
community guidelines
Community Expert ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

The solution mentioned above is not the right way to do it, and will not work consistently in all platforms. It's a bug, if anything, not a feature.

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 ,
May 12, 2022 May 12, 2022

Copy link to clipboard

Copied

It's a "bug" that works consistently for me, on two different Macs and with two different versions of Acrobat. I guess that makes it a (Mac-only) feature. Meanwhile, I find that with Acrobat XI on my office PC no matter how many items are in a dropdown list there's still white space at the bottom of the list that can be clicked on to de-select an item. Is this something that Adobe, in its wisdom, disabled in recent versions?

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 ,
May 25, 2022 May 25, 2022

Copy link to clipboard

Copied

LATEST

Thanks for this. Saved me a lot of time! 🙂

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

Make content for your business needs with Adobe Express.

Get started easily with free templates: