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

blank selection for dropdown

Participant ,
Jan 11, 2019 Jan 11, 2019

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
13.4K
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
1 ACCEPTED SOLUTION
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"});

View solution in original post

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

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

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

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.

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

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".

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

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

}

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

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

May I ask where to put the JavaScript?

 

 

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

As the Mouse Up event of your submit button.

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

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

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

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.

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

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

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

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

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

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

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.

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

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?

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 ,
May 27, 2024 May 27, 2024

2 years later in Adobe Acrobat 2020 this "bug" still works consistantly on window 10 - scroll to the bottom of the list in options pane and click the white space at the bottom and boom it clears and sets the default to null

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 ,
Apr 03, 2025 Apr 03, 2025
LATEST

If someone doesn't want to, or is having trouble getting the NULL back as defualt selection, you can also make the first or last selection a single space and select it as the default entry. Will make it look like the selection is blank and being at the beginning or end of the drop down, it won't be noticed.

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

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

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 ,
Apr 29, 2023 Apr 29, 2023

Thank you so much for giving me an easy answer!

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 ,
May 27, 2024 May 27, 2024

thank you so much for going back and adding your comment 2 years after - 2 years after that it's still saving people like me! scroll the botton of the list in options tab, click the white space below the list, boom. done. THANK YOU!! 

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 Beginner ,
Dec 03, 2024 Dec 03, 2024

I hope you are relaxing on the a beach somewhere! You deserve it. Thank you so much! I have spent 2 days, 100s of searches, at least 10 videoes on Adobe and JavaScript, trying to figure out how to do this so that the form can be printed and filled out manually, if desired. So simple!

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