justinmind-logo
 
Upvote 1

How do I set up a condition that checks if the field is empty AND also a number?

Answered Victor Conesa 11 years ago

How do I set up a condition to both check if the field is empty (Count (Field X) = 0) and then also check to see if the field contains numbers? I know there is the "isNum" constant. But I can't figure out how to make it part of the same condition so it checks for both. I tried coping the entire interaction and just setting up a basic condition of (Field X = isNum) but that didn't work. Any suggestions would be helpful, thanks!

Best Answer
photo

Create this condition:

249e0c8939d0ae4f2b2d935750b8afa5

Replies (14)
photo
1

You have to build a condition like this:


First drag the '&' function to the expression.


Then drag an '=' function to the first parameter and a 'RegExp' function to the other parameter.


Then drag Field X to the first parameter of the '=' function and also the first in the 'RegExp' function.


Go to the Constants tab and drag the text one 'Aaa' to the second parameter of the '=' function. By default, that constant is an empty text.


Finally, drag the isNum constant to the second parameter of the RegExp function.


The result will look like this:


(Field X = ) & (RegExp(Field X, isNum)


If you want to know more about those functions check this section of the user's guide

photo
1

So this worked, except I had to add N outside all of the brackets since we're trying to generate an error if the field is not a number or if it's empty. Sorry probably didn't really make that clear. But still got the right end result, so thanks!

photo
1

Cool!

photo
1

Well now it's not working. Do you ever have users have issues with something working then when coming back into the prototype it no longer works? Obviously you could have forgotten to save it but otherwise ever had this issue? It seems to happen to me occasionally and I've gotten very ardent about saving. Anyways I'll send you the file, not sure why it doesn't work now.

photo
1

We don't usually have customers with that kind of problem. We do know sometimes people think they finished creating the expression but it was incomplete because instead of dragging elements to the expression they just select them (in the expression builder's outline view for instance) and press ok. Of course sending us the prototype will be really helpful to try to trace what's the problem.

photo
1

I've gotten well rounded enough at Justinmind that I came up with my own solution. It didn't like that I was putting together the empty field condition and the number condition. It was basically invalidating anything in there. So I separated it into to two separate interactions that I knew worked using the count field and the isNum expression. My two interactions looked like this...Interaction 1 - Count(Field X)=0, Interaction 2 - N(RegEx(Field X, isNum)). This worked like a charm. I've found in my experience that sometimes when I overcomplicate things it almost always works better if I just break something out into separate interactions. I shouldn't have to per se but I rather break it out and work then hit my head against a wall on why some complicated or weird condition isn't working. Thanks again!

photo
1

Wow Phil, good job! I always get amazed at how far users can get without training!

photo
1

Create this condition:

249e0c8939d0ae4f2b2d935750b8afa5

photo
1

I am setting this to work off of my continue button. How do i get the continue button to navigate to the next page after all fields have validated? thanks

photo
1

Hi Steve, this condition should be attached to an event "on click" + "navigate to" (new screen). Tell me if this information is useful.

Greetings.

Files: nc.PNG
photo
1

Hi Ria I have 8 fields to check, do I have to add 8 inputs to the expression? thx

photo
1

Hello Steve, you can add the functions you need. I attach a capture of how it would look.

Greetings.

Ria.

Files: nc2.PNG
photo
1

I find this condition drag drop difficult to use. I can't replicate what you have in your screen capture.

photo
1

Hello, here is an example where you can see the interaction.

let me know if this is helpful to you.

Greetings.

Leave a Comment
 
Attach a file