Hi, I'm trying to verify a set of fields where, if the first name is not blank, then the address must be filled out. This is the code I have now - the first 'if' statement works fine:
-----------------------------------------
function ValidForm() {
if (document.request.r_name.value == "" || document.request.r_address == "" || document.request.re_email.value == ""
{
alert("You must enter please enter your name, address and email address."
;
document.request.r_name.focus();
return false;
}
if (document.request.f1name.value != "" || document.request.f1address.value == ""
{
alert("You must enter your f1-friend's address."
;
document.request.f1address.focus();
return false;
}
else
return true;
}
---------------------------
Here's the form fields:
<DIV ALIGN="left">Friend's Name:<BR>
<INPUT NAME="f1name" TYPE="TEXT" SIZE="30" MAXLENGTH="120" VALUE=""></DIV>
<DIV ALIGN="left">Friend's Address:<BR>
<INPUT NAME="f1address" TYPE="text" SIZE="30" MAXLENGTH="200"></DIV>
-------------------------------
the alet msg "You must enter your f1-friend's address" pops up regardless of whether or not I enter anything in the field. I only need it if the field (f1name) is not equal to blank.
Thanks in advance!
~ lahddah
-----------------------------------------
function ValidForm() {
if (document.request.r_name.value == "" || document.request.r_address == "" || document.request.re_email.value == ""
alert("You must enter please enter your name, address and email address."
document.request.r_name.focus();
return false;
}
if (document.request.f1name.value != "" || document.request.f1address.value == ""
alert("You must enter your f1-friend's address."
document.request.f1address.focus();
return false;
}
else
return true;
}
---------------------------
Here's the form fields:
<DIV ALIGN="left">Friend's Name:<BR>
<INPUT NAME="f1name" TYPE="TEXT" SIZE="30" MAXLENGTH="120" VALUE=""></DIV>
<DIV ALIGN="left">Friend's Address:<BR>
<INPUT NAME="f1address" TYPE="text" SIZE="30" MAXLENGTH="200"></DIV>
-------------------------------
the alet msg "You must enter your f1-friend's address" pops up regardless of whether or not I enter anything in the field. I only need it if the field (f1name) is not equal to blank.
Thanks in advance!
~ lahddah