title: single validation script for select dropdown
body: <p>I am creating a user form. In this I have textbox and a lot of number of select dropdown.
  After submitting I send all the value to database by $_POST. My form is like This:</p>
  
  <pre><code>     &lt;tr&gt;
           &lt;td&gt;Review Employee Id&lt;/td&gt;
           &lt;td&gt;&lt;input type="text" name="rcode" id="rcode"  class="genInputBox" /&gt;&lt;/td&gt;
       &lt;/tr&gt;
       &lt;tr&gt;
           &lt;td&gt;Quality of Delivery&lt;/td&gt;
           &lt;td&gt;
                &lt;select name="qd" id="qd"&gt;
                  &lt;option value=""&gt;Plz Select Ratting &lt;/option&gt;
                  &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;option value="4"&gt;4&lt;/option&gt;
                  &lt;option value="3"&gt;3&lt;/option&gt;
                  &lt;option value="2"&gt;2&lt;/option&gt;
                  &lt;option value="1"&gt;1&lt;/option&gt;
                &lt;/select&gt;
           &lt;/td&gt;
        &lt;/tr&gt;
  </code></pre>
  
  <p>And more select boxes.........</p>
  
  <p>and for select box validtion I am using like this</p>
  
  <pre><code>   var qd = document.product.qd.options[document.product.qd.selectedIndex].value;
         if (qd == "") {
             error_message = error_message + "Please select Rating In domain Knowledge\n";
             error = 1;
         }
  </code></pre>
  
  <p>I mentioned lot of select boxes in the form. So my question is can I use a single select box validation script for all select boxes?</p>
  
  <p>I use this answer In this manner</p>
  
  <pre><code>var sels = document.product.getElementsByTagName("select");
  for (var i=0,n=sels.length;i&lt;n;i++) {
    if (sels[i].selectedIndex&lt;1) {
      alert(sels[i].options[0]); // alerts Plz Select whatever
      sels[i].focus();
  
    error_message = error_message + "Please select drop down\n";
     error = 1; }
  }
     if (error == 1) {
      alert(error_message);
      return false;
      } else {
      return true;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>but now if a left only 1 single select drop down without check,then its show 10 error message for selectbox.</p>