Christine Joy Fuerte Christine Joy Fuerte - 5 months ago 51
Javascript Question

How to test multiple conditions using not equal?

My code is not working.

I am trying to test if my variable is not equal to any of my conditions.

function text(){
if( input!="BSIT" || input!= "BSBA"|| input!="BSN") { .. }

Answer Source

Those || should be &&s.

You want to test if all the conditions are true, not if any of them are true. || will return true as soon as at least one is true.

Also, as @nullpointer pointed out, you shouldn't compare strings via == or !=. See this post for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download