title: Simple form validation
body: <p>POST #1</p>
  
  <p>How can I validate this simple form (checking for empty field strings)?</p>
  
  <pre><code>                &lt;p&gt;Please select your Gift Certificate amount below. Please also enter your name and the Gift Certificate recipient's name. Once you click 'Buy Now' you will be sent to our Paypal site to complete the purchase.&lt;/p&gt;
  
                      &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;
          &lt;input type="hidden" name="cmd" value="_s-xclick"&gt;
          &lt;input type="hidden" name="hosted_button_id" value="sdsafsdafsadfdsafsdafsadfsadfsadfasdfsadfsdaf"&gt;
          &lt;table width="100%"&gt;
          &lt;tr&gt;
              &lt;td width="130"&gt;&lt;input type="hidden" name="on0" value="Amount"&gt;&lt;p&gt;Amount&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;select name="os0"&gt;
              &lt;option value="Option 1"&gt;$20.00&lt;/option&gt;
              &lt;option value="Option 2"&gt;$50.00&lt;/option&gt;
              &lt;option value="Option 3"&gt;$100.00&lt;/option&gt;
              &lt;/select&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="hidden" name="on1" value="To:"&gt;&lt;p&gt;To (Full Name):&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="os1" maxlength="60" size="30"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="hidden" name="on2" value="From:"&gt;&lt;p&gt;From (Full Name):&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="os2" maxlength="60" size="30"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;table width="100%" style="margin-top: 10px;"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="hidden" name="currency_code" value="CAD"&gt;
          &lt;p&gt;&lt;input type="image" src="BUTTON.jpg" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;&lt;/p&gt;
          &lt;img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;img src="../paypal_logo.jpg" alt="PayPal" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form&gt;
  </code></pre>
  
  <p>POST #2</p>
  
  <p>function validate_form()
  {
          valid = true;</p>
  
  <pre><code>    if ( document.GiftForm.os1.value == "" )
      {
          alert ( "Please fill in the 'Your Name' box." );
          valid = false;
      }
      return valid;
  }
  </code></pre>
  
  <p>-=-=-=-= Form</p>
  
  <pre><code>        &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post" method="GiftForm" onsubmit="validate_form( )"&gt;
          &lt;input type="hidden" name="cmd" value="_s-xclick"&gt;
          &lt;input type="hidden" name="hosted_button_id" value="sdsafsdafsadfdsafsdafsadfsadfsadfasdfsadfsdaf"&gt;
          &lt;table width="100%"&gt;
          &lt;tr&gt;
              &lt;td width="130"&gt;&lt;input type="hidden" name="on0" value="Amount"&gt;&lt;p&gt;Amount&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;select name="os0"&gt;
              &lt;option value="Option 1"&gt;$20.00&lt;/option&gt;
              &lt;option value="Option 2"&gt;$50.00&lt;/option&gt;
              &lt;option value="Option 3"&gt;$100.00&lt;/option&gt;
              &lt;/select&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="hidden" name="on1" value="To:"&gt;&lt;p&gt;To (Full Name):&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="os1" maxlength="60" size="30"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="hidden" name="on2" value="From:"&gt;&lt;p&gt;From (Full Name):&lt;/p&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="os2" maxlength="60" size="30"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;table width="100%" style="margin-top: 10px;"&gt;
              &lt;tr&gt;
                  &lt;td&gt;&lt;input type="hidden" name="currency_code" value="CAD"&gt;
          &lt;p&gt;&lt;input type="image" src="BUTTON.jpg" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"&gt;&lt;/p&gt;
          &lt;img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"&gt;&lt;/td&gt;
                  &lt;td align="right"&gt;&lt;img src="../paypal_logo.jpg" alt="PayPal" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form&gt;
  </code></pre>