• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 572
  • Last Modified:

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

0
earwig75
Asked:
earwig75
  • 2
1 Solution
 
_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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now