troubleshooting Question

JavaScript nested IF statement?

Avatar of IsaacWeathers
IsaacWeathersFlag for United States of America asked on
JavaScript
15 Comments1 Solution1531 ViewsLast Modified:
I am new to javascript, but I would assume that there is a way to nest IF statements, correct? I am trying to setup some form validation based upon whether a previous form element was set to Yes. So, in the example below, if Form("PairMe") = "Yes" then I want to require that they fill in Form("Pair_FirstName"). Is that possible with javascript?

Here's my first attempt at doing it, not sure where my problem is.

<script language="javascript">
function validateForm()
{
      if(document.Registration.PairMe.value=="Yes")
      {
            if(document.Registration.Pair_FirstName.value=="")
            {
            alert("Please enter the First Name of your partner.");
            return false;
            }
      }
}
</script>

Thanks!
ASKER CERTIFIED SOLUTION
sajuks

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros