title: Check if html form values are empty using Javascript
body: <p>I want to check a form if the input values are empty, but I'm not sure of the best way to do it, so I tried this:</p>
  
  <p><strong>Javascript:</strong></p>
  
  <pre><code>  function checkform()
      {
        if (document.getElementById("promotioncode").value == "")
      {
          // something is wrong
          alert('There is a problem with the first field');
          return false;
      }
  
      return true;
      }
  </code></pre>
  
  <p><strong>html:</strong></p>
  
  <pre><code>  &lt;form id="orderForm" onSubmit="return checkform()"&gt;
        &lt;input name="promotioncode" id="promotioncode" type="text" /&gt;
        &lt;input name="price" id="price" type="text" value="&amp;euro; 15,00" readonly="readonly"/&gt;
        &lt;input class="submit" type="submit" value="Submit"/&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>Does anybody have an idea or a better solution?</p>