title: Javascript search validation
body: <p>I have this code:</p>
  
  <pre><code>First name:
  &lt;input id="first_name" name="firstname" type="text" placeholder="First Name" /&gt;
  Last name:
  &lt;input id="last_name" name="lastname" type="text" placeholder="Last Name" /&gt;
  
  &lt;input id="search_order" type="Submit" value="Find Order" /&gt;
  
  &lt;span id="warning" style="visibility: hidden; color: red;"&gt;Please enter first and last name&lt;/span&gt;
  
  &lt;script&gt;
  document.getElementById("search_order").addEventListener("click", search);
  function search() {
      var fname = document.getElementById("first_name").value;
      var lname = document.getElementById("last_name").value;
      var name = fname + " " +  lname;
      if (fname == " " || lname == " ")
      {
          document.getElementById("warning").style.visibility = "visible";
          return;
      } else
          window.location = "http://bifoldsbidesign.com/?s=" + name + "&amp;post_type=project";
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Of which the search will always go through, even with the If statement checking if the values are empty?</p>
  
  <p>The code is live on the site <a href="http://bifoldsbidesign.com/search-for-your-order/" rel="nofollow noreferrer">http://bifoldsbidesign.com/search-for-your-order/</a> if that is of any help.</p>