cfif to check 2 variables and allow one or the other

I need my cfif to to allow one of 2 options, if neither option is met it should produce the error.

Can someone look at my sample and assist?

 
<cfif variables.emotion neq 0000 or variables.emotion neq 7777 >

<cfset ArrayAppend(errorarray, "You did not enter a valid emotion number")>
 </cfif>

Open in new window

earwig75Asked:
Who is Participating?
 
_agx_Commented:
Try either:

<cfif variables.emotion neq "0000" AND variables.emotion neq "7777" >
        <cfset ArrayAppend(errorarray, "You did not enter a valid emotion number")>
 </cfif>
                                 
OR

<cfif listFindNoCase("0000,7777", variables.emotion) eq 0>
        <cfset ArrayAppend(errorarray, "You did not enter a valid emotion number")>
</cfif>
0
 
earwig75Author Commented:
Thank you. I did resolve it while waiting for this reply... I just replaced the OR with an AND; so I basically used the first option.
0
 
_agx_Commented:
If you need to match the exact string 0000, and NOT 0 or 00, you want the 2nd example. If it doesn't matter, go with the 1st one.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.