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.
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"});
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.
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.
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".
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");
}
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"});
Copy link to clipboard
Copied
May I ask where to put the JavaScript?
Copy link to clipboard
Copied
As the Mouse Up event of your submit button.
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
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.
Copy link to clipboard
Copied
Command-click the selected dropdown item. It will become unselected, and the field will become blank.
Copy link to clipboard
Copied
That's in "edit fields"/"properties"/"options", by the way.
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?
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.
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for this. Saved me a lot of time! 🙂
Copy link to clipboard
Copied
Thank you so much for giving me an easy answer!
Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
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!