cfif to check 2 variables and allow one or the other

Posted on 2012-09-04
Last Modified: 2012-09-04
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")>

Open in new window

Question by:earwig75
    LVL 51

    Accepted Solution

    Try either:

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

    <cfif listFindNoCase("0000,7777", variables.emotion) eq 0>
            <cfset ArrayAppend(errorarray, "You did not enter a valid emotion number")>

    Author Closing Comment

    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.
    LVL 51

    Expert Comment

    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.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math ( While this method is not o…
    Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now