Skip to main content
Participant
January 20, 2017
Question

Validate Dropdown selections

  • January 20, 2017
  • 1 reply
  • 4589 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!

try67
Community Expert
Community Expert
January 20, 2017

You can't attach PDF files here. You should upload it to a sharing website like Dropbox or Google Drive and then post the link to it.