View Full Version : Weird if statement problem

07-28-2009, 11:38 AM

I'm trying to use the below if statement to say if a typed in name does not equal the name I'm expecting, an alert is thrown up.

But, the alert is thrown up even when I type in the correct name. Am I doing sth wrong?!

if (uni_name != "Bournemouth University" ||
uni_name != "British Universities Film and Video Council (BUFVC)" ||
uni_name != "Cambridge Imaging Systems (CIS)" ||
uni_name != "Glasgow Metropolitan College" ||
uni_name != "Royal Holloway, University of London" ||
uni_name != "University of Portsmouth") {
alert("Sorry, the institution '" +uni_name+ "' was not recognised or does not have access to this service.");

07-28-2009, 11:47 AM
Use the AND operator(&&) instead of ||

See http://en.wikipedia.org/wiki/De_Morgan%27s_laws