Expand my Community achievements bar.

SOLVED

Validating for no selection on Drop-Down boxes

Avatar

Level 2

Once again, I am stumped by seemingly simple things!

I have a drop down box with no default values. I want to display an error message when the user tries to exit without selecting anything. However, my validation script isn't working. Here's what I have set up:

Under the validate event of the Script Editor, I test for blank or null values:

this.rawValue == "" || this.rawValue == null;

Then under the Validation Script message on the Object > Value tab, I have this simple message:

"Please select a type."

Users are able to exit without selecting anything. However, when they actually do select something, then my validation message is shown. What is the correct way of doing this? Thanks for your help.

--Bruce

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

the syntax is similar in JavaScript.

if (this.isNull) {

          scriptObject.functionName();

}

View solution in original post

5 Replies

Avatar

Level 7

you could put this into the exit event instead (in formcalc):

if ($.isNull) then

    xfa.host.messageBox("Please select a type.")

    xfa.host.setFocus("$")

endif

Avatar

Level 2

Excellent. Thank you. Worked like a charm.

--Bruce

Avatar

Level 2

Okay, here's the thing. From this field, after checking for a null value, I need to call a Javascript function contained in a Script Object, so I need to find a way to do this null checking in Javascript, not FormCalc. Does anyone have any insight into how to make this work in Javascript? Thanks in advance for your help.

--Bruce

Avatar

Correct answer by
Level 10

Hi,

the syntax is similar in JavaScript.

if (this.isNull) {

          scriptObject.functionName();

}