title: How to combine two if statements into one?
body: <p>I know there is a much cleanlier way to write this than multiple if statements but when I try to combine them my validation stops working! This isn't good practice right? Or in this case is two different if statements okay? </p>
  
  <p>My code:</p>
  
  <pre><code>function validateForm() {
      var success = true;
      var x = document.forms["contestForm"]["firstName"].value;
  
      if (x == null || x == "") {
  
          addClass($('#firstNamespan'), 'formError');
          removeClass($('.validationError'), 'is-hidden');
          success = false;
      } else {
          removeClass($('#firstNamespan'), 'formError');
          addClass($('.validationError'), 'is-hidden');
      }
  
      var x = document.forms["contestForm"]["lastName"].value;
  
      if (x == null || x == "") {
          addClass($('#lastNamespan'), 'formError');
          removeClass($('.validationError'), 'is-hidden');
          success = false;
      } else {
          removeClass($('#lastNamespan'), 'formError');        
      }
      return success;
  }
  </code></pre>
  
  <p>My attempt to combine:</p>
  
  <pre><code>function validateForm() {
      var success = true;
      var x = document.forms["contestForm"]["firstName", "lastName"].value;
  
      if (x == null || x == "") {
          addClass($('#firstNamespan', '#lastNamespan'), 'formError');
          removeClass($('.validationError'), 'is-hidden');
          success = false;
      } else {
          removeClass($('#firstNamespan', '#lastNamespan'), 'formError');
      }
      return success;
  }
  </code></pre>
  
  <p>So what am I doing wrong? I also will need to add a birthday and e-mail validation but I wanted to get this cleaned up first before it became a monster of if else statements! Sorry for the extra non-helpful information its making me write more because I have to much code. Please feel free to edit and delete this once its posted. </p>