First, if
should be lowercase.
Then, you could do it like this:
if (inputServer !== undefined && inputUser !== undefined && inputPassword !== undefined) {
alert("it works!");
}
If you wanted to check if they were not undefined
OR null
you could do (and this is one of the rare circumstances when using double equality is useful):
if (inputServer != null && inputUser != null && inputPassword != null) {
alert("it works!");
}
And lastly, if you wanted to check if they weren't any falsy value (null
, undefined
, false
, -0
, +0
, NaN
, ''
), you could do:
if (inputServer && inputUser && inputPassword) {
alert("it works!");
}
Sidenote: You don't need to use typeof
in most normal circumstances -- that is unless undefined
is actually a variable defined somewhere in your program...
Fortunately, in ECMAScript 5.1 it's not possible to overwrite window.undefined
http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.1.3