title: Javascript function with multiple if statements not working
body: <p>All of my if statements work on their own, but when I have all of them inside the function, I cannot get all of them to work. </p>
  
  <pre><code>function validate()
  {
      var x = document.forms["myForm"]["patientName"].value;
      var y = document.forms["myForm"]["patientId"].value;
      var z = document.forms["myForm"]["patientEmail"].value;
      var yL = y.toString().length;
      var search1 = z.search("@");
      var search2 = z.search(".");
      if (myForm.emailReceipt.checked == true) {
      if (x == "" || y == "" || Z == ""){
              alert("Name, ID, and Email must be filled out");
          }else if (search1 == -1 || search2 == -1){
              alert("Please submit a valid email address");
          }
      if ((myForm.emailReceipt.checked == false) &amp;&amp; (x == "" || y == "" )) {
          alert("Name and ID must be filled out");
      }
      if (yL !== 8){
          alert("ID must be 8 digits long");
      }
  }
  </code></pre>