Skip to main content
Participating Frequently
December 22, 2021
Question

How do I make a required dropdown field option not a valid selection

  • December 22, 2021
  • 2 replies
  • 5603 views

Sorry if this is a amature question. I am new to the Javascript "Validate Script" side of Adobe Acrobat Pro
How do I make a required Dropdown field option not a valid selection using Validate script. I have 4 Options Under Dropdown:

  1. Select One (Not a valid choice)-Want to use it as a default "Title"
  2. Option 1- (Valid Required Choice)
  3. Option 2- (Valid Required Choice)
  4. Option 3- (Valid Required Choice)

As it stands now "Select One" can be used as a choice and user can move on with out actually selecting one.

Is this a possible thing?

Ive searched all over and even tried to modify other scripts from post to try and accomplish this with zero success. 

Other post I was looking at: See Post Here

Script peices is credit to: try76 

(This is what I copied off it to try and accomplish my goal, as the full one seem unnessisary to my useage)

var f1 = this.getField("Option 1");
var f2 = this.getField("Option 2");
var f3 = this.getField("Option 3");
if (event.value=="Select One") {
    f1.readonly = true;
    f2.readonly = true;
    f3.readonly = true;
    f1.required = false;
    f2.required = false;
    f3.required = false;
}

 

Thanks for any help. 

 

This topic has been closed for replies.

2 replies

Nesa Nurani
Inspiring
December 23, 2021

You can set so field is required if "Select One" is selected and if any other choice is selected field is not required, but you will need to use 'Calculation script' for that:

event.target.required = event.value == "Select One" ? true : false;

B.HallockAuthor
Participating Frequently
December 23, 2021

Thank you Nesa. I feel like thats closer. It highlights "Select One" with a red box and when the other 3 options are picked it doesn't have a red box. Isnt it suppose to shoot a message or something? I can still pass it up and ignore it basically. 

B.HallockAuthor
Participating Frequently
December 24, 2021

Yes, you can use zip code field for alert, but use waiver field name in script.

Use it like this:

if (this.getField("Waiver type field name goes here").valueAsString == " ")
app.alert("Please Select One of the Options Under Waiver Type");

 


Ran into a slight issue when I tested it more. Warning still pops up When "Waiver Type" isn't required per selection in "Coverage Type".
Only was able to get this script to work if I changed the Orange writing to "Dropdown7.0" vs one of the drop down options:

" " -blank title option

"Spousal-S"

"Individual-I"

"None-N"

Bernd Alheit
Braniac
December 23, 2021

Want you that the user can't select one of the options?

B.HallockAuthor
Participating Frequently
December 23, 2021

I want to make the 3 options the only options they can choose as a requirement. So if they select option 1, option 2, or option 3 from the dropdown, they can move on. But if they select "Select One" that's disabled and doesn't count as one of the  required choices and can't. Because it's just a instruction or title if you will.