Skip to main content
Participant
January 20, 2017
Question

Validate Dropdown selections

  • January 20, 2017
  • 1 reply
  • 4619 views

Hey everyone,

I am most certain this is a simple if statement, but since my java knowledge is pretty outdated, I need some help. I am creating an interactive pdf and I need to validate the form. I am using dropdown menus for the most part and I need a script to check to see if the default selection is still present. If so, I need a prompt to highlight  the dropdown menu that still has the default value present.  Can anyone help?

Thanks!

- G

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
January 20, 2017

You can use this code to do that:

var f = this.getField("Dropdown1");

if (f.valueAsString==f.defaultValue) {

    app.alert("You must fill in this field before submitting the file.",1);

    f.setFocus();

} else this.mailDoc();

big_gilAuthor
Participant
January 20, 2017

For some reason, this is not working. I just tested it and left one of the dropdown selections with the default value and no prompt or error code populates. I have attached this code within a button.

Thanks!

big_gilAuthor
Participant
January 21, 2017

So what happens when you click the button, exactly? Are there any error messages in the JS Console (Ctrl+J)?

Can you share the actual file?


I can not share the actual file (internal use only), nothing happens when I select the button with the code, no error messages or anything.

- G