Is it possible to nest IF statements in Javascript?
I'm talking about the following:
IF a=b
Do Something
IF b=c
Do Something
Else
do something.
I have the following script:
if(validateName(document.HMSTAPP.lastname.value)==false)
{
document.HMSTAPP.lastname.style.backgroundColor = 'yellow';
if(blnErrorFound == false)
{
alert("Enter a Last Name.");
document.HMSTAPP.lastname.focus();
blnErrorFound = true;
}
else
{
document.HMSTAPP.lastname.style.backgroundColor = 'white';
}
}
The process should be if the first IF statement is false then change the textbox to yellow and check the second IF statement. If the first IF statement is true then bypass changing the box to yellow and the inner IF and set the textbox to white.
I also tried ELSEIF {document....} and that didn't work. I'm assuming the ELSE statement is being associated with the inner IF.
Is there something I'm missing in the inner IF (eg. end if).
Thanks for any ideas or suggestions on how this may be accomplished?
I'm talking about the following:
IF a=b
Do Something
IF b=c
Do Something
Else
do something.
I have the following script:
if(validateName(document.HMSTAPP.lastname.value)==false)
{
document.HMSTAPP.lastname.style.backgroundColor = 'yellow';
if(blnErrorFound == false)
{
alert("Enter a Last Name.");
document.HMSTAPP.lastname.focus();
blnErrorFound = true;
}
else
{
document.HMSTAPP.lastname.style.backgroundColor = 'white';
}
}
The process should be if the first IF statement is false then change the textbox to yellow and check the second IF statement. If the first IF statement is true then bypass changing the box to yellow and the inner IF and set the textbox to white.
I also tried ELSEIF {document....} and that didn't work. I'm assuming the ELSE statement is being associated with the inner IF.
Is there something I'm missing in the inner IF (eg. end if).
Thanks for any ideas or suggestions on how this may be accomplished?