Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Script to check if user selected item from downdown list or not

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

14-04-2015

I have a script that runs when the form user exits a dropdown object after making a selection. I do not want the script to run if the dropdown object is left blank (user does not make a selection). I need to create an if statement to test if the user made a selection from the dropdown. All the items in the dropdown are 4 digit numbers.  I would prefer the if statement is in the Exit event. Is the following script correct?

if(dropdown1.isNull || dropdown1.rawValue.length !=4){

     xfa.host.messageBox("You need to make a selection, dropdown name");

}

else{

     put script to run here

}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

14-04-2015

It looks like your script is mostly right, but are you trying to do something extra in the message box? Did you mean to have the dropdown name in the title or as part of the message?

If you aren't allowing custom entry, you only need the null check. Of course, we're only talking about a millisecond or so to check the length of your string. So, you aren't asking any devices to do intense processing.

If I were asked to do this, this is what my script would look like.

750441_pastedImage_0.png

750442_pastedImage_1.png

If you are allowing custom entries, then you should specify what the problem is for the user.

750450_pastedImage_3.png

750449_pastedImage_2.png

Answers (3)

Answers (3)

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

14-04-2015

Thank you again - I appreciate your help.

Avatar

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
jasotastic81
Level 4

Likes

35 likes

Total Posts

329 posts

Correct Reply

43 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
jasotastic81
Level 4

14-04-2015

if (!this.isNull) , if(this.rawValue != null) , and if(this.rawValue !== null) give the same result in LiveCycle. The extra = in !== or === is to require the type be the same, as well. Since null assumes the type that you're comparing, it shouldn't make a difference.

Edit: I should point out that this is only referring to Adobe's "interpretation" of JavaScript. Per W3C standards, those would not be the same. For example:

function myFunction() {

    var x = "";

    var y = null;

    document.getElementById("result").innerHTML = (x === y);

    //returns false

}

Avatar

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile

Avatar
Validate 100
Level 3
DKinsley
Level 3

Likes

9 likes

Total Posts

545 posts

Correct Reply

5 solutions
Top badges earned
Validate 100
Validate 50
Validate 25
Validate 10
Validate 1
View profile
DKinsley
Level 3

14-04-2015

I see now what I was doing wrong. Thank you - much appreciated!

One other question, to script is not null, is this correct (again for a dropdown in exit event...

if(this.rawValue !=null){

//do something

}

or should it be !==null (with two == signs instead of one?)